Media Library widget does not work inside LB

Created on 21 May 2019, over 5 years ago
Updated 16 July 2024, 4 months ago

Problem/Motivation

To reproduce:

  1. Using 8.7.x
  2. Enable Layout Builder and Allow overrides on Basic page
  3. Install Media and Media library module
  4. Add a Media reference (Image bundle) and use Media library form widget to the Basic block type
  5. Create a new node
  6. Try to add/edit a custom block and upload a media
  7. Media Library widget does not work (should open Media Library popup)

Works as expected when editing custom block independently from LB.
Also, the same setup worked in 8.6.x :( regression?
Also, does not work with IEF widget.

Proposed resolution

Fix Ajax subform handling inside block config form?

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component
Layout builderΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡·πŸ‡ΊRussia anydigital

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand john pitcairn

    I cannot reproduce this in Drupal 10.1.

  • πŸ‡¨πŸ‡­Switzerland handkerchief

    A similar Problem here:
    Core: 10.1.4

    Not sure if the error in the screenshot is related to this issue. Because I didn't find a useful pattern of the error. But when I clicked the "Add media" Button, nothing is happening besides the ajax loading gif.

  • Status changed to Postponed: needs info 8 months ago
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    I'm unable to replicate this issue on a fresh 11.x install of Drupal.

    I've followed these steps:

    1. Install a fresh Drupal 11 standard site
    2. Enable Media, Media library & Layout Builder
    3. Add Layout Builder and allow content item overrides to the article content type.
    4. Add a media field to the basic block block type with the media library widget
    5. Add media library to the basic_html text format
    6. Create an article and go to Layout Builder
    7. Add a basic block to the article. Verify that the media library opens correctly both in CKEditor & in the Media library field.

    Since this can't be replicated I'm marking this as postponed. If you can replicate this with just core please update this with the steps. Thanks!

  • πŸ‡¨πŸ‡ΊCuba ccolumbie

    In d10.2.2 editing a block with layout builder and the media library widget in existing blocks I have the following error when trying to add a Media or select an existing one:

    message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 403\nDebugging information follows.\nPath: /media-library?destination=/node/8/layout&_wrapper_format=drupal_ajax&ajax_form=1&media_library_opener_id=media_library.opener.field_widget&media_library_allowed_types%5Bimage%5D=image&media_library_selected_type=image&media_library_remaining=1&media_library_opener_parameters%5Bfield_widget_id%5D=field_hc_image%3A-settings-block_form&media_library_opener_parameters%5Bentity_type_id%5D=block_content&media_library_opener_parameters%5Bbundle%5D=hotel_counters&media_library_opener_parameters%5Bfield_name%5D=field_hc_image&media_library_opener_parameters%5Bentity_id%5D=3329&media_library_opener_parameters%5Brevision_id%5D=28621&hash=R00G-VI2Jd-tylep7AkBs4y4KjJiYQYYbDpLcDZsRXk&views_display_id=widget\nStatusText: Forbidden\nResponseText: {"message":"Non-reusable blocks must set an access dependency for access control."}'
    ​
    name: "AjaxError"
    ​
    stack: "@http://localhost:8080/core/misc/ajax.js?v=10.2.5:196:32\n@http://localhost:8080/core/misc/ajax.js?v=10.2.5:1916:3\n"

    Without creating a new block it doesn't happen. Can somebody help me? I see that this error message comes from the checkAccess function in core/modules/block_content/src/BlockContentAccessControlHandler.php

  • πŸ‡ΊπŸ‡ΈUnited States electrokate

    I am having the same error:

    "
    An AJAX HTTP error occurred.
    HTTP Result Code: 500
    Debugging information follows.
    Path: /layout_builder/add/block/overrides/node.1323636/0/content/inline_block%3Ablank?_wrapper_format=drupal_dialog.off_canvas&ajax_form=1
    StatusText: Internal Server Error
    ResponseText: The website encountered an unexpected error. Try again later.InvalidArgumentException: "href" is an invalid render array key. Value should be an array but got a string. in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php). Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 98)
    __TwigTemplate_8d2346e8554847dcc657b61c95520401->doDisplay() (Line: 360)
    Twig\Template->yield() (Line: 335)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 33)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 491)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 133)
    __TwigTemplate_2d85fd5afdb7d12e10591724d18de052->doDisplay() (Line: 360)
    Twig\Template->yield() (Line: 335)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 33)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 491)
    Drupal\Core\Render\Renderer->doRender() (Line: 504)
    Drupal\Core\Render\Renderer->doRender() (Line: 504)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 49)
    __TwigTemplate_b416f63f3ad7568340839e6cba4665df->doDisplay() (Line: 360)
    Twig\Template->yield() (Line: 335)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 33)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 491)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 153)
    Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 152)
    Drupal\Core\Render\Renderer->renderRoot() (Line: 36)
    Drupal\Core\Ajax\OpenDialogCommand->getRenderedContent() (Line: 148)
    Drupal\Core\Ajax\OpenDialogCommand->render() (Line: 43)
    Drupal\Core\Ajax\AjaxResponse->addCommand() (Line: 838)
    Drupal\media_library\Plugin\Field\FieldWidget\MediaLibraryWidget::openMediaLibrary()
    call_user_func_array() (Line: 69)
    Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse() (Line: 112)
    Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 239)
    Symfony\Component\HttpKernel\HttpKernel->handleThrowable() (Line: 91)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    "

    When trying to use the media library insert button inside a block in layout builder.

  • πŸ‡ΊπŸ‡ΈUnited States electrokate

    Following up on my previous post. The error was due to the mini-pager view inside the gin_lb template. I made a patch to fix it. Hope it helps someone! https://www.drupal.org/project/gin_lb/issues/3461861 πŸ› Media Library Widget broken when adding block in layout builder Active

Production build 0.71.5 2024