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: temporary custom gradient not saving #56896
Conversation
…re they'll always return true for this test if the color property is default (#000)
e371581
to
a847daa
Compare
Flaky tests detected in fbd438c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7160971758
|
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!
It does fix the inability to save a custom gradient with the default colour, but now it's not possible to save the default gradient with a custom name. I wonder if we shouldn't be checking that both name and gradient are set to default, and if either one has changed assume the change is deliberate and save?
One thing I noticed while trying to reproduce the issue on trunk is that it's only impossible to save a gradient with the default name if there are no other gradients saved already. After successfully saving one, I'm able to save however many I want with the default name. Not sure why this happens though.
Thanks for testing! Oh dang 😆 I didn't see that.
Good point on the default name. I'll take look. |
…ch changes to the slug Added tests
I've fixed that I think, and added some tests. I was returning the wrong default value from Working on this PR highlighted another logical error in trunk: that the regex 2023-12-11.10.30.47.mp4Might require a bit of a refactor so I'd say unrelated to this bug, which fixes the bug in the color/gradient conditional test order. |
Have WIP PR here as a follow up to this one: |
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.
Works nicely for me, and is a definite improvement over what we have on trunk. Thanks for adding the tests, too!
Saving custom gradients is working now, and saving single colors is still working:
2023-12-12.16.39.49.mp4
LGTM! ✨
Thanks @andrewserong! |
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.
Thank you for working on this (and for adding tests!!) I've left a small comment, but otherwise this looks great!
slugPrefix: string, | ||
{ slug, color, gradient }: Color | Gradient | ||
) { | ||
): Boolean { |
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.
Minor comment, but we should use boolean
instead of Boolean
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.
Oh! Thanks. I'll fix in an upcoming, related 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.
Great catch, thanks Marco!
Fixes #56865
What?
Refactors
isTemporaryElement
test in thePaletteEdit
component.Why?
Gradient elements contain both color and gradient properties, therefore they'll always return true for the
isTemporaryElement
test if the color property is default (#000
).How?
Ensuring we test for
gradient
values first.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Before
2023-12-08.15.38.45.mp4
After
2023-12-08.16.07.29.mp4