Libraries attached to content block fields are not included in the editor

Created on 25 May 2024, 6 months ago
Updated 14 June 2024, 5 months ago

Problem/Motivation

II came across another bug while adding a content block in guttenberg.

My block has a field which I am attaching a custom library to in a preprocess function from a custom module with $variables['#attached']['library'][] = 'MYMODULE/MYLIBRARY'; Im doing this inside hook_preprocess_field()

When rendering in Gutenberg editor this library is not attached.

This renders correctly on the front end, its just not included when previewing it in edit mode.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Pipeline finished with Failed
    6 months ago
    Total: 1165s
    #181603
  • Pipeline finished with Failed
    6 months ago
    Total: 1271s
    #181641
  • Issue created by @loze
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles
  • Pipeline finished with Success
    6 months ago
    Total: 1282s
    #181675
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    loze β†’ changed the visibility of the branch 3449711-libraries-attached-to to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    loze β†’ changed the visibility of the branch 3449711-libraries-attached-to to active.

  • Status changed to Needs review 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    I dug around a little in this and realized that the libraries wernt being included because renderContentBlock() was returning a plain json response with the rendered html only and no libraries.

    I switched this to return an ajaxResponse and populate the block in the editor with drupals ajax commands since that has the benifit of including any attached libraries in the render array

    It probably needs some cleaning up, but it seems to be working from my initial testing

  • Pipeline finished with Success
    6 months ago
    Total: 241s
    #181733
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    This should also render the block using the front end theme templates. Right now it doesn't that yet.

  • Pipeline finished with Success
    6 months ago
    Total: 349s
    #182709
  • Pipeline finished with Success
    6 months ago
    Total: 342s
    #182730
  • Pipeline finished with Canceled
    6 months ago
    Total: 16s
    #182750
  • Pipeline finished with Success
    6 months ago
    Total: 372s
    #182751
  • First commit to issue fork.
  • Pipeline finished with Success
    6 months ago
    Total: 282s
    #183268
  • Pipeline finished with Success
    6 months ago
    Total: 346s
    #183281
  • Status changed to Fixed 6 months ago
  • πŸ‡΅πŸ‡ΉPortugal marcofernandes

    Nicely done! Now implemented in the proper way πŸ˜‰

  • πŸ‡¨πŸ‡¦Canada drclaw

    This is awesome! πŸ‘

    But a small side effect / regression is that blocks are now rendered using the admin theme which means any template overrides / preprocessors in the default theme won't be used when rendering the block. Will post a new issue shortly with an MR πŸ™

  • Pipeline finished with Failed
    6 months ago
    Total: 263s
    #191022
  • Pipeline finished with Failed
    6 months ago
    Total: 115s
    #191029
  • Pipeline finished with Failed
    6 months ago
    Total: 113s
    #192854
  • Pipeline finished with Failed
    6 months ago
    Total: 113s
    #192861
  • Pipeline finished with Failed
    6 months ago
    Total: 397s
    #193733
  • Pipeline finished with Failed
    6 months ago
    Total: 487s
    #194383
  • Pipeline finished with Failed
    6 months ago
    Total: 872s
    #194388
  • Pipeline finished with Failed
    6 months ago
    Total: 4986s
    #194836
  • Pipeline finished with Failed
    6 months ago
    Total: 1065s
    #194880
  • Pipeline finished with Failed
    6 months ago
    Total: 119s
    #195386
  • Pipeline finished with Failed
    6 months ago
    Total: 119s
    #195388
  • Pipeline finished with Success
    6 months ago
    Total: 341s
    #195393
  • Pipeline finished with Failed
    5 months ago
    Total: 2078s
    #196149
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Failed
    5 months ago
    Total: 350s
    #209372
  • Pipeline finished with Success
    5 months ago
    Total: 474s
    #209512
  • Pipeline finished with Success
    5 months ago
    Total: 1015s
    #216173
  • Pipeline finished with Success
    5 months ago
    Total: 1769s
    #216179
  • Pipeline finished with Failed
    5 months ago
    Total: 298s
    #216188
  • Pipeline finished with Success
    5 months ago
    #216189
  • Pipeline finished with Success
    4 months ago
    Total: 168s
    #229051
  • Pipeline finished with Success
    4 months ago
    #229077
  • Pipeline finished with Success
    4 months ago
    #229225
  • Pipeline finished with Success
    4 months ago
    Total: 173s
    #229228
  • Pipeline finished with Failed
    4 months ago
    Total: 728s
    #233756
  • Pipeline finished with Success
    4 months ago
    Total: 250s
    #245743
  • Pipeline finished with Failed
    3 months ago
    Total: 170s
    #267565
  • Pipeline finished with Success
    3 months ago
    Total: 145s
    #267566
  • Pipeline finished with Skipped
    3 months ago
    #274032
  • Pipeline finished with Success
    3 months ago
    Total: 191s
    #276430
  • Pipeline finished with Success
    3 months ago
    Total: 197s
    #276437
  • Pipeline finished with Success
    2 months ago
    Total: 201s
    #289571
  • Pipeline finished with Success
    2 months ago
    Total: 286s
    #289575
  • Pipeline finished with Success
    2 months ago
    Total: 234s
    #289606
  • Pipeline finished with Success
    2 months ago
    Total: 269s
    #289610
  • Pipeline finished with Failed
    about 2 months ago
    Total: 524s
    #303618
  • Pipeline finished with Success
    about 2 months ago
    Total: 281s
    #303625
  • Pipeline finished with Failed
    about 1 month ago
    Total: 263s
    #306531
  • Pipeline finished with Failed
    28 days ago
    Total: 115210s
    #318528
  • Pipeline finished with Success
    28 days ago
    Total: 1057s
    #320095
  • Pipeline finished with Success
    28 days ago
    Total: 1913s
    #320110
  • Pipeline finished with Skipped
    1 day ago
    #345628
Production build 0.71.5 2024