UX: Provide a better category system for the plugins

Created on 19 September 2023, about 1 year ago
Updated 20 September 2023, about 1 year ago

Problem/Motivation

The current category system is inherited from the core which provide a very basic and not very flexible system.
The current implementation creates the plugins groups on the fly in alterForm() in StylePluginManager.

There is a single sorting performed on the groups. Their machine name is translated and automatically sorted by alphabetical order. It's interesting as it provides a default way of sorting the form but it doesn't make much sense as it can bring some categories that are really not that important to the top just because they start with an A in your language.

Steps to reproduce

Go to the layout builder, insert a block, check UI Styles groups order in english and in an other language.

Proposed resolution

We could probably propose a category plugin definition to allow setting multiple options on each category.
Here is a yml example we could provide.

category1:
  label: "My category"
  weight: 0
  open: false

category2:
  label: "My other category"
  weight: 1
  open: true

Remaining tasks

Create the plugin definition.
Update the different themes and design systems with the new category definition.

User interface changes

None

API changes

This would probably have an impact on the way the category would be linked to the plugin as we may want to prioritize machine names before labels as reference strings.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France nicoloye

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nicoloye
  • 🇫🇷France pdureau Paris

    The current category system is inherited from the core which provide a very basic and not very flexible system.

    I am not very confortable about introducing our own category mechanism. There is nothing in Drupal Core / Contrib / Symfony / PHP we can reuse or build our categories upon.

    We could probably propose a category plugin definition to allow setting multiple options on each category.

    So, in styles definitions, the category will be a machine name reference to those plugins instead of a free text?
    Why not :) but are we introducing a compatibility break? What would be the behaviour if the category is not defined?

    Anyway, thanks for pushing this proposal. If we do this, it is something we need to build at the UI suite level, to have the same mechanism for Components (ui_patterns), Styles (ui_styles) and CSS Variables (ui_skins).

  • 🇫🇷France nicoloye

    I am not very confortable about introducing our own category mechanism. There is nothing in Drupal Core / Contrib / Symfony / PHP we can reuse or build our categories system upon?

    I understand, from what I've seen we are already using the core system right now and categories are only strings attached to a plugin through the category attribute. This is a very basic way of dealing with a categorization concept and it lacks proper control on the category order and initial intended display. I may lack knowledge on other mechanism and am open to discuss other solutions that I may not be aware of.

    So, in styles definitions, the category will be a machine name reference to those plugins instead of a free text?

    I would say so yes. I think it's a better way of guaranteeing a proper primary key between the component plugins and their categories.

    Why not :) but are we introducing a compatibility break? What would be the behaviour if the category is not defined?

    It would definitely be a breaking change so we need to discuss the proper way of introducing it everywhere it makes sense. I suggest we open a discussion about it in the next UI Suite meeting.

Production build 0.71.5 2024