- Issue created by @tomsaw
- 🇫🇷France Grimreaper France 🇫🇷
Hi,
This seems to be the bug that 🐛 Drupal 10.1: Layout Builder: Styles preview no more working on sections Fixed was supposed to fix, or is it something else?
- 🇩🇪Germany tomsaw Essen
Im running Drupal 10.1.7 and also tried the latest dev of ui_styles.
But the bug resists! Setting ui_styles back to 1.6.0 all works fine.Actually the release 1.7.0. intended to solve a bug, created it on my end. Very interessting.
Gonna investigate the code...
- 🇩🇪Germany tomsaw Essen
Ok found something mad:
This nested loop always ends in continue because
$layout_index
is a string in most if not all cases!public static function preRender(array $element): array { $styles_manager = \Drupal::service('plugin.manager.ui_styles'); /** @var \Drupal\layout_builder\SectionStorageInterface $section_storage */ $section_storage = $element['#section_storage']; $delta = 0; $max = \count($section_storage->getSections()); foreach (Element::children($element['layout_builder']) as $index) { foreach (Element::children($element['layout_builder'][$index]) as $layout_index) { if ($delta >= $max) { break 2; } if (!\is_numeric($layout_index)) { continue; } ...
Can i leave this to you since you're very much into it!
- last update
about 1 year ago 62 pass - Status changed to Needs work
about 1 year ago 9:01am 15 December 2023 - 🇫🇷France Grimreaper France 🇫🇷
Thanks for the investigation!
Not sure it is the correct fix and why in my case it was working, but it will speed up the resolution.
If you are using other modules interacting with Layout Builder could you provide the list of name, version and potential patch applied please? Like Layout Builder Lock, Restrictions, etc.
Also, the latest dev version is the 8.x-1.7, so that's why you have the same result: https://git.drupalcode.org/project/ui_styles/-/network/8.x-1.x?ref_type=...
- Assigned to Grimreaper
- Merge request !49Issue #3408778 by TomSaw, Grimreaper: Section styles missing in layout_builder layout editing → (Merged) created by Grimreaper
- last update
11 months ago 67 pass - Status changed to Needs review
11 months ago 1:34pm 22 January 2024 - 🇫🇷France Grimreaper France 🇫🇷
Hi,
The proposed solution in MR 46 is not the correct one.
Regarding core/modules/layout_builder/src/Element/LayoutBuilder.php::buildAdministrativeSection,
return [ '#type' => 'container', ... 'layout-builder__section' => $build, ];
There should always be a 'layout-builder__section', so I wonder how I ended up with numeric keys in 🐛 Drupal 10.1: Layout Builder: Styles preview no more working on sections Fixed .
- 🇫🇷France Grimreaper France 🇫🇷
Ok, I had numeric keys instead of 'layout-builder__section' when the Section Library module is enabled...
I will give a look at why it alters the render array and if possible to fix in it.
- 🇫🇷France Grimreaper France 🇫🇷
For website using Section Library, Please use the patch in #3416266-4: Do not use array_pop or array_push → .
- 🇩🇪Germany tomsaw Essen
Sry for not having reacted on #6 :/
MR 49 works 🥳
Because of #11: I'm not using section_library → so there must be another module in my setup changing the array index from key to numeric.
My other layout_builder modules:
- drupal/layout_builder_operation_link
- drupal/layout_builder_restrictions
- drupal/layout_builder_st
- drupal/layout_disable
- drupal/layout_library
- drupal/lb_direct_add
- 🇫🇷France Grimreaper France 🇫🇷
Thanks for your feedback.
No, it should not be numeric. The problem was when Section Library was present. So MR 49 revert partially the commit in 🐛 Drupal 10.1: Layout Builder: Styles preview no more working on sections Fixed that was about the numeric.
-
Grimreaper →
committed 44391a1c on 8.x-1.x
Issue #3408778 by TomSaw, Grimreaper: Section styles missing in...
-
Grimreaper →
committed 44391a1c on 8.x-1.x
- Issue was unassigned.
- Status changed to Fixed
11 months ago 5:30pm 22 January 2024 Automatically closed - issue fixed for 2 weeks with no activity.