Fix Color Picker Angle Reset on Gradient Type Change#76595
Fix Color Picker Angle Reset on Gradient Type Change#76595ciampo merged 11 commits intoWordPress:trunkfrom
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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Vedant-Gandhi! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Pull request overview
This PR updates the CustomGradientPicker’s gradient type switching logic so that when a user switches from linear → radial → linear, the previously selected linear angle is preserved instead of resetting.
Changes:
- Add a
useRef-backed “last linear orientation” cache inGradientTypePicker. - When switching back to
linear-gradient, restore the cached orientation (or fall back to the default angle). - Clean up constants imports related to the previous orientation defaulting behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mirka
left a comment
There was a problem hiding this comment.
Approach looks good overall 👍 Can we also add tests to cover this new behavior?
The native counterpart (index.native.js) has the same pattern of stripping orientation when switching to radial, so it likely has the same issue. Out of scope for this PR, but worth noting here. Maybe it's fine to leave it that way, since we're migrating away from the React Native implementation.
|
E2E failures don't seem related, merging anyway when all remaining tests have passed. |
* fix: import sequence * fix: remove typefixture for AngleControl * feat: add test cases * doc: add public facing component to changelog instead of gradient picker * fix: restore default linear gradient orientation as horizontal * feat: update test case to set horizontal gradient as default * feat: update test case default result to be more generic * feat: improve restore test case to use a non-default value * refactor: move changelog to unrelease section * doc: add bug fixes section in changelog --- Co-authored-by: Vedant-Gandhi <vedantgandhi28@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: patrickwc <patrickwclanden@git.wordpress.org>
What?
Closes #72433
Why?
When we switch the gradient type in color picket from linear to radial and then back to linear the selected angle in linear resets.
How?
Add logic to memoize the last angle selected.
Demo
20260317223909525.mp4