Problem/Motivation

Original GH issue: https://github.com/nuvoleweb/ui_patterns/issues/331
Original GH PR: https://github.com/nuvoleweb/ui_patterns/pull/332

I have a lot of patterns now and the list of patterns is not sorted alphabetically (not sorted at all?)

I'd like to have patterns at least sorted by id asc :-)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Grimreaper created an issue. See original summary.

Grimreaper credited barig.

grimreaper’s picture

Issue tags: +Prague2022

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Active » Needs review

Compared to GH, I have updated the PR with the code review comment taken into account.

duaelfr’s picture

I'm afraid it will be confusing that the list is sorted by some invisible data.
Plus, it's going in the opposite direction of #3311464: Sort UI Pattern definitions that I've been using on my projects for a long time. Should we introduce a settings somewhere to allow sorting to be configured? Should we replace that list of links by a tablesort showing the label and the id?

g4mbini’s picture

grimreaper’s picture

Thanks @DuaelFr to point this out.

I think we should agree on a mecanism and stick to it because I have the same problem on UI Styles: #3314936: Sort styles alphabetically in the library

I am not in favor of a settings. Let's keep as much as possible the UI Suite ecosystem settingsless as possible. To be only API.

And I do not think that there is enough space for a tablesort. Also @pdureau told me that maybe one day it will be a good idea that the listing of patterns that do the summary could be extracted as a block plugin to not be linked to the library page.

So we have stuff to discuss.

From what I see from the PR linked in the linked issue, it is based on a category key with a fallback on module label (themes seems to not be handled in CategorizingPluginManagerTrait). In the end it is the plugin label that is used for sorting, if I am not mistaken.

I agree that a sort on something the site builder cannot see can be confusing but I had in mind in case of translation, the sort will be different from one language to the other but maybe that is not important.

g4mbini’s picture

pdureau’s picture

> I am not in favor of a settings. Let's keep as much as possible the UI Suite ecosystem settingsless as possible.

I totally agree with that :)

> I agree that a sort on something the site builder cannot see can be confusing but I had in mind in case of translation, the sort will be different from one language to the other but maybe that is not important.

This doesn't look like a blocking point.

Also, some teams, including mine, are sometimes putting plugin labels in between parenthesis for internal/private use. How the sorting will work for them?

grimreaper’s picture

If sorting acts on labels by alphabetical order, then all internal/private patterns will appear first if in parenthesis.

And will appear in last position if prefixed by an underscore. But I don't see it elegant the underscore in the pattern label, in the machine name I can understand but would prefer to avoid too).

grimreaper’s picture

Assigned: Unassigned » grimreaper

Discussed in monthly meeting: sort by label and try to find a sort algorythm that ignores parenthesis.

grimreaper’s picture

Title: Sort patterns library alphabetically by ID on /patterns page » Sort patterns library alphabetically by label on /patterns page

Update issue title.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Closed (duplicate)

Closing in favor of #3311464: Sort UI Pattern definitions.

Finally making the change in the UI patterns manager will impact the library too.