-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
: dedupe palette element slugs
#65772
Conversation
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. |
PaletteEdit
: dedupe palette element slugs
5ee626b
to
4c9b408
Compare
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 fixing this one @ramonjd, I'm sure it was annoying for people maintaining color palettes 👍
This PR tests well for me. I didn't run into any issues and only left a couple of very minor nits as inline comments.
✅ Custom colors with various duplicate slugs now work
✅ Same for custom gradients
✅ Duplicate named colors work both frontend and in the editors (site/post)
LGTM 👍
Screen.Recording.2024-10-03.at.3.11.32.pm.mp4
…a generic type parameter. The linter was complaining that I wasn't doing the same, even though I was using the same inherited types. Whatever. It could probably be optimized, but it's unrelated to the scope of this PR
526fc89
to
f135898
Compare
Sounds good! I rebased, fixed conflicts, and will merge as soon as CI is green |
There was a conflict while trying to cherry-pick the commit to the wp/6.7 branch. Please resolve the conflict manually and create a PR to the wp/6.7 branch. PRs to wp/6.7 are similar to PRs to trunk, but you should base your PR on the wp/6.7 branch instead of trunk.
|
@aaronrobertshaw I tried but there's a conflict when merging. I'm about to go offline for the week — would you be able to take care of manually backporting when you're back offline? Otherwise I'll do it myself when I come back online on Monday |
* First pass at deduping palette element slugs. * Addressing TypeScript errors where PaletteEditListViewProps is using a generic type parameter. The linter was complaining that I wasn't doing the same, even though I was using the same inherited types. Whatever. It could probably be optimized, but it's unrelated to the scope of this PR * Add changelog * Make use of PaletteElement type consistent * Address feedback on deduplicate util * Use count rather than index for new slugs --------- Co-authored-by: ramonjd <[email protected]> Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: ciampo <[email protected]>
Manual backport #65905 |
* First pass at deduping palette element slugs. * Addressing TypeScript errors where PaletteEditListViewProps is using a generic type parameter. The linter was complaining that I wasn't doing the same, even though I was using the same inherited types. Whatever. It could probably be optimized, but it's unrelated to the scope of this PR * Add changelog * Make use of PaletteElement type consistent * Address feedback on deduplicate util * Use count rather than index for new slugs --------- Co-authored-by: ramonjd <[email protected]> Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: ciampo <[email protected]>
* `PaletteEdit`: dedupe palette element slugs (#65772) * First pass at deduping palette element slugs. * Addressing TypeScript errors where PaletteEditListViewProps is using a generic type parameter. The linter was complaining that I wasn't doing the same, even though I was using the same inherited types. Whatever. It could probably be optimized, but it's unrelated to the scope of this PR * Add changelog * Make use of PaletteElement type consistent * Address feedback on deduplicate util * Use count rather than index for new slugs --------- Co-authored-by: ramonjd <[email protected]> Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: ciampo <[email protected]> * Update CHANGELOG section --------- Co-authored-by: ramonjd <[email protected]> Co-authored-by: ciampo <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: aaronrobertshaw <[email protected]>
* First pass at deduping palette element slugs. * Addressing TypeScript errors where PaletteEditListViewProps is using a generic type parameter. The linter was complaining that I wasn't doing the same, even though I was using the same inherited types. Whatever. It could probably be optimized, but it's unrelated to the scope of this PR * Add changelog * Make use of PaletteElement type consistent * Address feedback on deduplicate util * Use count rather than index for new slugs --------- Co-authored-by: ramonjd <[email protected]> Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: ciampo <[email protected]>
What?
Part of #43197
First pass at deduping palette slugs
Why?
The color palette uses the palette item name to generate a slug. So,
Test 1
will becustom-test-1
.If there are identical names, the slugs would normally be the same. Slugs should be unique identifiers so they can be correctly applied as CSS vars.
How?
When updating palette item names, check for duplicate slugs. If duplicates are found, update those slugs.
Testing Instructions
In Site Editor > Global Styles > Colors > Palette create multiple custom colors and gradients.
Give all or some of each the same name.
Save and try to apply your custom colors in the editor.
They should work in the front and backend.
Testing Instructions for Keyboard
Screenshots or screencast
Given a series of duplicate names:
The custom palette is still operable due to unique slugs:
Kapture.2024-10-01.at.16.45.27.mp4
Which are saved to global styles and output in the frontend