DRAFT ToolsPanel: Trigger onDeselect
/onSelect
callbacks directly
#61694
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Instead of using an effect hook to run some callbacks runs them from an event.
Why?
Simplification for maintainability. I noticed this while working on #60621.
How?
onDeselect
andonSelect
callbacks into state accessible bytoggleItem
.toggleItem
which is the event handler for menu item clicks.Investigation needed to be “ready for review”
Before this change there it seems there was some potential for triggering
onSelect
oronDeselect
without actually interacting with the menu items. If that’s the case then this is a breaking change but there must not be tests covering such.I’m walking myself through to see what needs verification. There’s two types of items—default and optional.
Their controls are always exposed so seemingly
onSelect
andonDeselect
aren’t even applicable but do these callbacks run for when an item is "customized" and "reset"? If so thenonSelect
would be called when an item’s control changes its value from default. Also after Fix sticking “Reset” option inToolsPanel
#60621onDeselect
would be called when an item’s control changes its value back to default. Also controlled updates might do the same so those should be covered as well.Their controls aren’t exposed until either:
In this case changing its value via its control isn’t possible so
onSelect
can’t be triggered other than through the menu item button. Once it is exposed, interaction with its control is not meant to cause the control to become hidden (and at least one e2e test catches this) soonDeselect
also cannot be triggered except through the menu item button.In this case is
onSelect
being called? There’s a unit test for this but it doesn’t assertonSelect
. Coverage should also exist for a controlled update restoring the default value I think.It looks like I’ll need to review the unit tests and either verify the above behaviors are specified or revise/add tests to do so.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast