fix(tooltip): propagate press and hover event objects to children - #5044
Open
aliyilmaztech wants to merge 1 commit into
Open
fix(tooltip): propagate press and hover event objects to children#5044aliyilmaztech wants to merge 1 commit into
aliyilmaztech wants to merge 1 commit into
Conversation
Tooltip called the wrapped children's onPress, onHoverIn and onHoverOut handlers without any arguments, so the event object was swallowed and parent callbacks received undefined. Forward the original GestureResponderEvent/MouseEvent to the children handlers and type TooltipChildProps accordingly. Closes callstack#5003 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes Tooltip’s event forwarding so that child callbacks receive the original event objects (instead of undefined) when Tooltip internally invokes them, aligning behavior across native press and web hover interactions.
Changes:
- Forward
GestureResponderEventto the child’sonPresshandler when invoked byTooltip. - Forward
MouseEventto the child’sonHoverIn/onHoverOuthandlers on web. - Add unit tests covering press (native) and hover (web) event propagation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/components/Tooltip/utils.ts | Widens TooltipChildProps handler typings to accept the corresponding event objects. |
| src/components/Tooltip/Tooltip.tsx | Updates internal press/hover handlers to forward the received event object to child callbacks. |
| src/components/tests/Tooltip.test.tsx | Adds regression tests verifying event objects are passed to onPress, onHoverIn, and onHoverOut. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Tooltipinvokes the wrapped children's handlers itself, but it called them without any arguments:So any consumer callback wrapped in a
Tooltipreceivedundefinedinstead of the event, e.g.onPress={(e) => e.nativeEvent...}crashed or silently misbehaved on Android/iOS. The same applied toonHoverIn/onHoverOuton web.This PR forwards the original
GestureResponderEvent/MouseEventto the children handlers and typesTooltipChildPropsaccordingly, so the event object reaches parent callbacks.Related issue
Closes #5003
Test plan
yarn test,yarn lintandyarn typecheckpass.src/components/__tests__/Tooltip.test.tsx:onPresswith an event object (this test fails onmain),onHoverIn/onHoverOutreceive the event object.onPressnow receives the event instead ofundefined.No API change other than the widened (previously argument-less) handler types on
TooltipChildProps.