Skip to content

fix(tooltip): propagate press and hover event objects to children - #5044

Open
aliyilmaztech wants to merge 1 commit into
callstack:mainfrom
aliyilmaztech:fix/tooltip-press-event-propagation
Open

fix(tooltip): propagate press and hover event objects to children#5044
aliyilmaztech wants to merge 1 commit into
callstack:mainfrom
aliyilmaztech:fix/tooltip-press-event-propagation

Conversation

@aliyilmaztech

Copy link
Copy Markdown

Motivation

Tooltip invokes the wrapped children's handlers itself, but it called them without any arguments:

return props.onPress?.();

So any consumer callback wrapped in a Tooltip received undefined instead of the event, e.g. onPress={(e) => e.nativeEvent...} crashed or silently misbehaved on Android/iOS. The same applied to onHoverIn/onHoverOut on web.

This PR forwards the original GestureResponderEvent/MouseEvent to the children handlers and types TooltipChildProps accordingly, so the event object reaches parent callbacks.

Related issue

Closes #5003

Test plan

  • yarn test, yarn lint and yarn typecheck pass.
  • Added unit tests in src/components/__tests__/Tooltip.test.tsx:
    • mobile: pressing the trigger calls the children's onPress with an event object (this test fails on main),
    • web: onHoverIn/onHoverOut receive the event object.
  • Repro from the issue (https://snack.expo.dev/@szado/rnp-tooltip-onpress-bug): the child's onPress now receives the event instead of undefined.

No API change other than the widened (previously argument-less) handler types on TooltipChildProps.

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>
Copilot AI lite review requested due to automatic review settings August 12, 2026 14:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GestureResponderEvent to the child’s onPress handler when invoked by Tooltip.
  • Forward MouseEvent to the child’s onHoverIn/onHoverOut handlers 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tooltip: onPress event object is not propagated to parent component on native

2 participants