Ability to Set Categories to Expanded/Collapsed

Created on 18 May 2022, over 2 years ago
Updated 20 April 2023, over 1 year ago

Problem/Motivation

Love this module, very helpful for editing pages. When you get a lot of blocks and Categories added it can become a very long list.

Proposed resolution

It would be great to be able to set Categories as either expanded or collapsed on opening to focus on the most used Categories and hide the less used more obscure ones.

✨ Feature request
Status

Fixed

Version

1.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States b0b Bethlehem, PA

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡«πŸ‡·France vbouchet

    Hi @b0b,

    Thanks for suggesting. I agree that the browser lacks flexibility for now, specially given that it is accessible to content editors so we should be able to tailor it based on their specific needs.
    I have just pushed some code on the 1.x-dev branch to introduce an alter hook so we can programmatically alter the browser. I added an example in the layout_builder_browser.api.php with the closing off the categories:

    function hook_layout_builder_browser_alter(array &$build, array $context) {
      // Alter the placeholder of the search textfield.
      $build['filter']['#placeholder'] = t('Block name');
    
      // Collapse the categories other than "Common".
      foreach ($build['block_categories'] as $category_key => &$category) {
        if ($category_key === 'common' || !isset($category['#type']) || $category['#type'] !== 'details') {
          continue;
        }
    
        $category['#open'] = FALSE;
      }
    }
    

    I don't know if we should really have the option from the configuration form of the categories as it is opening the door to infinite requests around the personalisation of the browser via the config (I want an illustrative icon, I want to display the number of block in each category like "Category name (14)", ...).

    I am not closing the issue for now to keep the discussion open but at least the original request can now easily be addressed via a small hook_alter().

  • I would really like to see this feature implemented. The key advantage of having the collapsible categories is if you have a lot of blocks per category, the author doesn't need to scroll a ton to see all available categories. Providing the ability to start categories as collapsed will make items more discoverable.

  • πŸ‡ΊπŸ‡ΈUnited States b0b Bethlehem, PA

    Thanks for the hook. That is helpful for me, but code is not an option for everyone. I would argue this isn't really asking for a new feature. It's just config for a feature that already exists, collapsing categories by clicking. :)

    • vbouchet β†’ committed b9898f56 on 8.x-1.x
      Issue #3281138 by vbouchet: Ability to Set Categories to Expanded/...
  • Status changed to Fixed over 1 year ago
  • πŸ‡«πŸ‡·France vbouchet

    Hi,

    I just pushed a commit which adds an "opened" checkbox which drives the expanded/collapsed behaviour on the browser form. It is on the dev version and will be part of the next release (1.6).

    Thanks,

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

Production build 0.71.5 2024