Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alphabetically sort blocks in global styles #45678

Closed
wants to merge 1 commit into from
Closed

Alphabetically sort blocks in global styles #45678

wants to merge 1 commit into from

Conversation

dsas
Copy link
Contributor

@dsas dsas commented Nov 9, 2022

What?

The blocks in global styles firstly list the core blocks in an undefined order, and then the non-core blocks also in an undefined order. This change lists the core blocks alphabetically by title, and then non-core blocks alphabetically by title.

Why?

This gives a more predictable order of blocks when using global styles. It's a quick initial solution for #44840

How?

The core blocks are sorted by title according to locale specific sorting rules, and then non-core blocks are sorted in the same way and then returned together.

Testing Instructions

  1. Install a plugin which gives non-core blocks, e.g. jetpack or coblocks.
  2. Open the site editor
  3. Open the styles menu on the right to open the global styles sidebar
  4. Press 'Blocks' at the bottom of the sidebar
  5. Notice the core blocks are listed in alphabetical order followed by non-core blocks in alphabetical order
  6. Search for blocks, the results will also be returned in alphabetical order.

Screenshots or screencast

Before After
image image

The blocks in global styles firstly list the core blocks in an
undefined order, and then the non-core blocks also in an undefined
order. This change lists the core blocks alphabetically by title, and
then non-core blocks alphabetically by title.

This gives a more predictable order of blocks when using global styles.
@codesandbox
Copy link

codesandbox bot commented Nov 9, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Nov 11, 2022
@apeatling apeatling self-requested a review January 6, 2023 20:01
Copy link
Contributor

@apeatling apeatling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and confirmed that blocks in global styles are now in alphabetical order. Checking through the rest of the project this also seems to be the accepted way to sort. 👍

Screenshot 2023-01-06 at 12 02 32 PM

@apeatling apeatling enabled auto-merge (squash) January 9, 2023 18:25
@jasmussen
Copy link
Contributor

Yep, let's go with this. If we need curation we can do better (such as subheadings) than just arbitrary reordering.

@apeatling apeatling disabled auto-merge January 13, 2023 19:24
@apeatling apeatling enabled auto-merge (squash) January 13, 2023 19:25
@richtabor
Copy link
Member

Gave this a once-over; alphabetizing works well here.

What's the reasoning on sorting non-core blocks separately?

CleanShot 2023-01-14 at 19 06 45@2x

@dsas
Copy link
Contributor Author

dsas commented Jan 15, 2023

@richtabor It sorts core blocks above other blocks currently. I don't understand why so I opted to preserve that behaviour in this PR, assuming there's a good reason.

@dsas dsas closed this by deleting the head repository Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants