Repository navigation
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. |
|
Size Change: +10.5 kB (+0.14%) Total Size: 7.66 MB 📦 View Changed
|
|
Flaky tests detected in 71aa610. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29251187430
|
|
Thanks for looking into this @aduth! Fair point about the focus order. The idea of the editing zone is to keep the user in the same color picking flow with a familiar UI, instead of the friction of sending them somewhere else to manage colors and come back. On close (save or cancel) focus returns to where it was. You're right that for SR users the order of landing on the name field can be confusing, especially when no color is chosen yet. I'll iterate on that and adjust the focus for these cases. Regarding reusing the PaletteEdit: I personally don't think it fits here. In a popover it doesn't scale. The list of custom colors pushes the rest down, and the experience can be quite messy if there are quite some colors. It also adds a second way to pick colors (the circle options, which are a way to "select" a pre-saved color in that context) next to the square swatch on top, which is more confusing than familiar in this context. |
Co-authored-by: Cursor <cursoragent@cursor.com>
8dc3737 to
ab91d9a
Compare
🤖 PR meta 🤖📦 Bundle sizeSize Change: +7.17 kB (+0.09%) Total Size: 8.01 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
|
# Conflicts: # packages/block-editor/src/components/color-palette/test/__snapshots__/control.jsdom.test.jsx.snap
|
Fixed some merge conflicts. Sorry for the pings! A bad merge triggered requests to codeowners. Taking the chance to ping @WordPress/gutenberg-design, would love to get some eyes on this if anyone has time for feedback. |
|
Thanks for the ping! Thanks for the work, for contributing. At a glance, this looks pretty cool, I notably like the circular plus button to add new "custom swatches". For that reason I would say the blocker to this work isn't design, but to address the reasonable comments by Andrew, and then to connect with the fine folk interacting with #74930 who are solving a tangential issue. If you can thread the needle on both, this feels like a cool contribution. |
|
Thanks @jasmussen! Happy to hear the direction feels right from a design perspective. I've worked through the a11y feedback. Left a bit more context on this comment. Adding or editing a color now goes to the picker first instead of the name field. So the focus issue about moving backwards should be resolved. It also returns to the swatch after saving, cancelling, or deleting. The + tile is now a listbox option and the delete confirmation is announced. @aduth, when you get a chance, I'd love to hear if this covers what you had in mind, or if there's anything else I should look at 🙏 I also left some feedback on #74930 (comment). Happy to keep iterating and see how we improve this area. |
|
Thanks for working on this. This is just my opinion, but I am hesitant to implement this feature. This is because, internally, it means directly manipulating global styles through the block instance's toolbar. What happens if that color palette is already applied to other blocks? If a user modifies or removes a custom color palette solely to color a specific block, it will affect all blocks and styles where that palette is applied. This, of course, also applies to global styles, but since the user is interacting with the block sidebar, they might not realize that the change will impact the entire site. I would like to hear your thoughts on this concern. |
|
Thanks Aki! that's a fair thing to raise. I believe that's kind of the point, though. Not being able to manage colors without leaving the creation flow is exactly what this is trying to fix. From the feedback I gathered it's a real blocker when building a site and kind of the expectation of many builders (heard the same for typography). A few guardrails can be that picking a color still works the same way, clicking a swatch still only sets the block attribute. Editing is a separate action (intentional) behind the pencil, with a form and an explicit save. The colors are grouped and named, so you can see that you're touching something that's part of a palette. And it's meant to only show up for people who can already edit global styles. Having said this, you're right that there's no communication that the change applies everywhere. I see that as something fixable, maybe communicating in the form and/or snackbar? |
|
Good concerns, good instincts. I don't have a strong opinion leaning in either one direction or the other, so to help facilitate a path forward, I'd rather connect some dots. In the Advanced panel, we have a "Push to global styles" button, which converts any local styles to global. While that is precedence for allowing the editing of global styles locally, it does validate Akis point, as I've heard lots of feedback by wp.com users who were confused about this button, notably before it had a confirm dialog which was added for the same reason. In that sense, if we do go with something that creates global changes, it seems like we should at least invoke the same modal dialog that this button invokes. Separately, @fcoveram has carefully explored how to improve style inheritance visualisation. The latest direction I've chatted with him about involves an ellipsis menu somewhere in the inspector: shows style inheritance information, and features buttons to reset to inherited styles and potentially also the same push to global styles, just moved to that menu. In the latter case, the modal would continue to be part of it, and all this is mostly conceptual at this point. Is that helpful? |

What?
🔗 link to test in playground
Adds inline color-palette editing to the block inspector's color picker. While editing a page/post you can now manage palette colors directly from the color control instead of switching to global styles. There a different capabilities depending on the palette:
All edits persist to the user's global styles entity with optimistic updates and snackbar feedback, and preview live on the canvas as you drag.
In terms of UX, after trying a few different directions I found that the way it could work best would be by not moving too far from the design language we have now for the palette and adding a few buttons and states.
Regarding implementation, the direction I took was to have this behind a private prop (as we have some other preceding examples).
The way it works is the following:
+button in the Custom color palette so you can add them from there. These two affordances are there, because the latter may not be reachable depending of the context (if there are too many custom colors, or if the popover is opened in a way that's trimming some content and only showing the top)A few notes:
Included a fix for bug I've found with the color picker when the colors were changing fast. It became noticeable while debugging in Firefox. I've commited that separately in case we want to take it out of the PR and take care of it independently.Took this out since Fix Color Picker Cursor Shaking Issue #80205 was merged.the full block stylesheet.
setImmutablycopy in@wordpress/editorbecause no package exports a public one (block-editor and global-styles-engine both keep theirs internal)Why?
Managing colors when editing content was really a pain. If you are testing out colors for the website you are building you want to be able to save them to your palette in the same context, without the need to go to global styles or writing an hex code to later save in a different screen.
The idea was to have this only for custom colors. While demoing it to @Mamaduka and @richtabor at WCEU they suggested that it'd be also interesting to have this same functionality for theme colors.
How?
ColorPalettereceives an editing config keyed by each paletteslug:fullvalueWhen there's no value (slug), then it's read only.
Per the repo's guidance, the editing config is passed via a private prop (the same pattern as
globalStylesDataKey, etc)obtained through
unlock(). It does not appear in the public props type.if the capabilities are there, then the palette will show up different UIs for the different use cases.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
color-palette-inline-editing.mp4
Use of AI Tools
Cursor/Claude