Problem/Motivation

The list of layouts presented in the Layout Builder UI is provided by a controller, which is not alterable like a form is.

Proposed resolution

The item list can be given a specifier (I forget what it's called in the theme system) that allows for more specific preprocess functions to target it.

Additionally, this gives string array keys to the rest of the render array instead of leaving it as numerically indexed.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

Status: Active » Needs review
FileSize
1.21 KB
tim.plunkett’s picture

Here it is with some test coverage. The FAIL patch is equivalent to the interdiff.

(I've renamed the existing layout_builder_field_block_theme_suggestions_test module and test to not only test field blocks, but as a home for all LB theme suggestion tests)

The last submitted patch, 3: 3096034-layoutlist-3-FAIL.patch, failed testing. View results

zrpnr’s picture

Status: Needs review » Reviewed & tested by the community

This is a nice improvement, I tested locally and the patches in #3 FAIL and PASS respectively.

  1. +++ b/core/modules/layout_builder/src/Controller/ChooseSectionController.php
    @@ -90,10 +90,10 @@ public function build(SectionStorageInterface $section_storage, $delta) {
    +      '#theme' => 'item_list__layouts',
    

    This adds a theme hook name which allows this layout to be specifically overridden.

  2. +++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderThemeSuggestionsTest.php
    @@ -54,6 +54,18 @@ protected function setUp() {
    +    $assert_session->pageTextContains('layout_builder_theme_suggestions_test_preprocess_item_list__layouts');
    

    This test shows both that the theme hook suggestion is working and also that the individual element in the list can be changed.

This will make it possible to theme the layout options in the "Add Section" panel, and the tests ensure that this theme hook name won't get removed in the future after contrib modules might depend on it.

webchick’s picture

Looks like a nice, simple patch.

I inquired with @tim.plunkett as to the BC implications, but there are none. item_list__boogiedboogiedboo (direct quote ;)) will resolve to just item_list if not found.

LGTM! I would go ahead and commit it now, but we are currently in a freeze for RC1.

The last submitted patch, 3: 3096034-layoutlist-3-FAIL.patch, failed testing. View results

The last submitted patch, 3: 3096034-layoutlist-3-FAIL.patch, failed testing. View results

  • webchick committed e3873cc on 9.0.x
    Issue #3096034 by tim.plunkett, zrpnr: Allow customization of the list...

  • webchick committed f506f76 on 8.9.x
    Issue #3096034 by tim.plunkett, zrpnr: Allow customization of the list...
webchick’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Ok, committed and pushed to 9.0.x and 8.9.x.

I feel that since this is a contributed project blocker, to allow iteration on a known UX headache, and the change itself is non-invasive with no BC implications, it should be backported to 8.8.x as well, but since we're currently in RC for 8.8, I need to get approval on that.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

alexpott’s picture

Status: Patch (to be ported) » Fixed

8.8.x is out of support so this will not be backported :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.