-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
PaletteEdit: Fix order numbers #52212
PaletteEdit: Fix order numbers #52212
Conversation
It is a draft now. |
Thanks for the PR @megane9988 Could you rebase this PR? It would also help to have a description of how to test. Thank you! |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
47aac7f
to
9888332
Compare
Thanks for the update to this PR @megane9988 and for the tests 🙇🏻 So to summarize: Gutenberg was trying to create slugs for colors using translated strings, e.g., This is working pretty well for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
This PR is working as expected and will also resolve two issues, #55185 and #51230.
7c6c80130e8a3a5ecbc25d0896d0aee6.mp4
As a follow-up, we should apply the same logic not only when a new color is "added" but also when a color label is "updated". As the screencast below shows, after an item with the correct slug is added, reapplying the same label will result in the incorrect slug being applied.
c408a0d4cd2bf3cbffb42f07b3925409.mp4
This means that we apply the getNameAndSlugForPosition()
function here as well and completely stop the slug generation logic from relying on the color label:
gutenberg/packages/components/src/palette-edit/index.tsx
Lines 226 to 232 in 33056a4
onChange( { | |
...element, | |
name: nextName, | |
slug: | |
slugPrefix + | |
kebabCase( nextName ?? '' ), | |
} ) |
packages/components/CHANGELOG.md
Outdated
### Bug Fix | ||
- `PaletteEdit`: Fix order numbers for color palette ([#52212](https://github.com/WordPress/gutenberg/pull/52212)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is causing a conflict, so could you rebase it again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like "PaletteEdit
: Fix number incrementing of default names for new colors added in non-en-US
locales" would be more helpful here, given the specific scope of the fix.
Is it much effort to include it in this PR? It would be good to fix the flow in one go. But also happy for it to be a quick follow up |
Regarding that issue, I think it's okay to address it in a follow-up since we probably need to add more tests. I plan to address it as part of a tracking issue, #57309. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ready to merge as an iterative improvement, once @t-hamano's feedback is addressed 👍
The renaming case may be a bit more complicated than the new color case, so I understand why we'd want to do that in a follow up. We also need to figure out which part of the chain is responsible for the name/slug validation (deduplication) logic — I kind of think it has to be provided by the consumer rather than the PaletteEdit component itself, but that's a separate discussion. Maybe it will turn out that the consumer needs to be responsible for the entire name/slug generation logic as well.
33fe907
to
6635428
Compare
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Thanks for the teamwork here, folks. @megane9988 are you okay to look at a follow up? Otherwise I can add it to my TODO list for later. Thank you! 🍺 |
Using FSE to change styles on a page template. When using the English language in site and add new colors to Styles, the default name appear with numbers in order. However, when switching to Japanese language, the sequential order numbers did not work anymore in the default name. Gutenberg was trying to create slugs for colors using translated strings, e.g., 色 6 but that didn't pass the regex new RegExp( ^${ slugPrefix }color-([\d]+)$ ) This commit hardcodes the English `color-` slug fragment to avoid this. Updates unit tests. --------- Co-authored-by: megane9988 <megane9988@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
What?
For #51230
Why?
copilot:summary
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast