-
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
Fix sticking “Reset” option in ToolsPanel
#60621
Conversation
58577f0
to
3007db7
Compare
Size Change: +1 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
086f577
to
d25ef9b
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.
🙇
if ( ! isMenuItemChecked && wasMenuItemChecked ) { | ||
if ( ! isMenuItemChecked && isValueSet && wasMenuItemChecked ) { | ||
onDeselect?.(); | ||
} |
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 effect that triggers this runs more often now that flagItemCustomization
get called when removing a value. That was causing onDeselect
to be called multiple times and this change fixed that.
As an aside, I experimented with a little refactor to not call these (onSelect
/onDeselect
) from an effect and it seemed to work well and simplifies things a bit. I wanted to keep changes minimal so I've left it out but if that sounds good I'd happily make a PR for it.
// Force a menu item to be checked. | ||
// This is intended for use with default panel items. They are displayed | ||
// separately to optional items and have different display states, | ||
// we need to update that when their value is customized. | ||
// Updates the status of the panel’s menu items. For default items the | ||
// value represents whether it differs from the default and for optional | ||
// items whether the item is shown. | ||
const flagItemCustomization = useCallback( |
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 comment seemed out of date because the callback is already being used from optional panel items and now, of course, it’s being used to also “remove” a customization flag.
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. |
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.
Looks good and tests well. ✅
I'd personally add a CHANGELOG entry, but that's not a requirement.
Thanks @stokesman 🙌
This reverts commit 3007db7.
Because they should not cause themselves to be hidden.
d25ef9b
to
fa554e4
Compare
Me too, I just tend to wait for approval and try sparing conflict fixes. Thanks for testing and reviewing Marin ❤️. |
What?
Ensures the “Reset” action of tools panel’s menu items is present only when an item’s value is set.
Why?
Currently once a panel item has had its value set the ”Reset” option becomes enabled but it gets stuck that way even if the original value has been restored. This doesn't cause much of a problem so fixing it could be described as UI/UX polish.
Further, this is extracted from a larger effort in another branch to ensure defaults of block supports are represented in the controls. It can work without these changes but the UI discrepancy is perhaps more glaring in such a context.
How?
true
).Testing Instructions
In the Editor
It's important to clear the value by using the same swatch as before. If you actually switch back to the original value by using its swatch then “Reset” will be enabled. This is a separate issue and fixing it also depends on these changes.
In Storybook
Testing Instructions for Keyboard
Not sure it’s required. The instructions above aren’t exclusively for pointing devices. I'll add more detailed instruction if need be.
Screenshots or screencast
Before
stuck-reset.mp4
After
unstuck-reset.mov