I'm trying to use this module in conjunction with the Layout Builder Modal module, but I'm getting the following error when trying to load a node's layout page: "Argument 1 passed to Drupal\Component\Utility\UrlHelper::buildQuery() must be of the type array, null given, called in /var/www/web/core/modules/contextual/contextual.module on line 180". I believe it's happening because this module (lb_ux) is moving the contextual links to a different position in the render array when it's building the administrative section, and then the layout_builder_modal module is trying to alter the non-existent contextual links at it's prior location.

I'm not sure what the best approach to resolving this would be, but one I've come up with is to move the code currently in LayoutBuilderUX::buildAdministrativeSection() to a preprocess function, and then altering the weight of this preprocess function so that it runs last. This way, other modules can still adjust contextual links.

Comments

rromore created an issue. See original summary.

rromore’s picture

StatusFileSize
new11.12 KB
piggito’s picture

Status: Active » Needs review
StatusFileSize
new11.12 KB

Re-rolled patch

piggito’s picture

StatusFileSize
new12.22 KB
new12.22 KB

Current approach isn't right yet cause we get Warning: Invalid argument supplied for foreach() in Drupal\layout_builder_modal\LayoutBuilderModal::preRenderContextual() in this line https://git.drupalcode.org/project/layout_builder_modal/-/blob/8.x-1.x/s...
This error is caused by the fact that we move layout_builder preRender along with lb_ux preRender logic after any other pre_render function but layout_builder_modal expects layout_builder's preRender to add layout_builder key in build array.

IMO we should isolate lb_ux's preRender as a pre_render callback and use hook_module_implements_alter to make this pre_render run as last in the list.
Attached patch implements this proposal, please let me know if you agree on this approach and mb we can update issue summary.

piggito’s picture

StatusFileSize
new12.27 KB
new504 bytes

For those who need it I'm also attaching a patch including the fix in The "cog" icon to edit block settings doesn't display when "Show content preview" is disabled

piggito’s picture

Please ignore the last patch including The "cog" icon to edit block settings doesn't display when "Show content preview" is disabled cause I found that the patch in that issue wasn't ready yet (see https://www.drupal.org/project/lb_ux/issues/3116402#comment-13631976)
I'm also hiding the file to avoid highlighting it.

Review and further work should go on patch at #4

i.mcbride’s picture

StatusFileSize
new12.25 KB

This is a reroll of #4 that will apply against the Drupal 11 compatible version of the module.