[Tooltip] Refactor event handling #23092
Merged
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.
Review by commit helps understand the refactoring process.
We're currently (sometimes) composing user-event handlers in the Tooltip event handlers. The current implementation is hard to parse (e.g. when coming back to the component after some time) and doesn't follow existing patterns.
I refactored it in a couple of steps:
handleEnter
andhandleLeave
)on*
props instead of handling behaviorchildren.props
) otherwise simply assign (e.g ininteractiveWrapperListeners
)The only behavior that changed is the order of events for focus events (cdbad40#diff-ec0479377a3497fa2a9c6db5b8a61bbd82b435648c4994ff7d6b9948c6d026a7L883-R883). Previously you'd see
onOpen
beforeonFocus
. Now the order is reverse which is consistent with the other event triggers.Curious about the size impact. I'd be fine with a couple of added bytes if this means that I don't have treat events differently when working with the Tooltip.
Edit: Size win as well.