-
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
Palette Edit: Don't discards colors with default name and slug #54332
Conversation
Flaky tests detected in 676611a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7296048303
|
b2d4cb0
to
1547507
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.
The changes proposed in this PR make sense to me, although I'd like to hear thoughts from other folks too.
I also wanted to flag a related issue, which is going to be happening more often if this PR gets merged: entries with the same color name and/or value all appear as selected at the same time:
- ColorPalette: make component more resilient to color entries with same color
value
and/orname
#43197 - Global Styles - Custom Colors given the same name cannot be applied properly #49593
It would be great if we could look into fixing those issues as a follow-up
When I merged the latest trunk into this PR and resolved the conflict, I discovered #56896 regarding the gradient custom palette. The screencast below shows how to apply the default gradient color, but we discovered that a warning error is logged in the browser. However, this error also appears to occur on trunk, so I think it needs to be fixed separately. 922efb48fcabfe2594b7994698e47c2a.mp4 |
Adding @ramonjd @tellthemachines and @andrewserong as reviewers as they've been also working on |
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'm strangely attracted to this approach because:
- It removes a complexity
- It removes a lot of code anyway
- It returns us to a state from which we might try alternatives
- It hands more power and choice to the user
/** | ||
* Checks if a color or gradient is a temporary element by testing against default values. | ||
*/ | ||
export function isTemporaryElement( |
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 actually think this is a decent approach to removing the complexity. Why do we remove "default" values? To keep the list clean? We could rather trust the user to control how they want to create custom colors/gradients.
The following doesn't make much sense, but why not?
2023-12-21.11.02.16.mp4
The only thing we could probably address here is the lack of default value on the first item of the gradient:
It has an empty value and can be saved.
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.
The following doesn't make much sense, but why not?
That's a good point... maybe the user knows they're going to add a few custom colors and quickly goes to create them and then decides to go back later to update their colors? It might be nice to allow these sorts of interactions rather than try to predict too much, so I'm really liking the direction of this PR.
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'm strangely attracted to this approach because:
+1, I really like the approach here! I think going for simplicity where we can is a good approach, and in practice, it feels quite good to me that you hit "+" and then new things are created and its up to the user to delete the ones they don't want.
The only issue I ran into is with a bit of inconsistency in creating gradients, not sure if it's related to what Ramon observed about an empty value being able to be saved, but when I go to add the first gradient, it has an empty value, but the second one isn't empty:
2023-12-21.13.49.22.mp4
Co-authored-by: Ramon <[email protected]>
Thanks forthetesting, @ramonjd, @andrewserong!
Thanks for finding that problem! This also occurs with trunk, so it should be a problem that needs to be fixed separately. The cause is that if the custom gradient palette does not yet exist, this condition will be d7aca5dc537dcf27116c8e267dad9fe9.mp4 |
I'm starting to think it might be better to resolve the above issues first before tackling this PR. Whether the For example, add props like @ciampo Please let me know if you have any ideas 🙏 |
I'd be fine with either personally, since as you mention that's happening on trunk. Let's see what Marco thinks, but if it makes it easier to land this PR first before looking at that other issue, that would sound reasonable to me! |
I agree with Andrew, let's resolve any feedback left and merge this PR, as it is an improvement over To recap, here are some follow-ups:
Unfortunately, I don't currently have time to work on this — @t-hamano / @andrewserong / @ramonjd , would any of you be able to look into it? |
OK, I have summarized the issues to be addressed in #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.
Sounds like we all agree, let's merge! ✨
(Looks like there's just a changelog conflict to resolve 🙂)
Great stuff! 🚢 |
Fixes: #37861
Related to #37496
What?
This PR will not discard colors with the default name (
Color-{number}
) and default color (#000
) in thePaletteEdit
component.Why?
I have looked at the changes made in #37496 and this PR makes two main changes:
However, my feeling is that the newly added color will have an appropriate name and slug so that the color no longer needs to be considered a "temporary" color.
In addition, you can never save a color that is considered a temporary color (i.e., one whose name is in the form
color {number}
and whose HEX color is#000
). To me, this behavior feels more like a bug.How?
I removed the code related to the
isTemporaryElement()
function that determines if a color is temporary or not, so that colors with default name are not deleted. I also adjusted variable names and comments.Note: The
PaletteEdit
component generates a slug from the input string, but problems exist regarding non-Latin and multibyte characters. See #49711 and #39210 for details.Testing Instructions
Color 1
,Color 2
, andColor 3
should be created.Screenshots or screencast
34561cfcc445476fa0c4bb874199df15.mp4