Skip to content

Read hover callbacks from the live Pressability config at invocation (#59363) - #59363

Closed
rozele wants to merge 1 commit into
react:mainfrom
rozele:export-D126767220
Closed

rozele wants to merge 1 commit into
react:mainfrom
rozele:export-D126767220

Conversation

@rozele

@rozele rozele commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Pressability._createEventHandlers destructured onHoverIn/onHoverOut out of
this._config once, and getEventHandlers memoises the handler object for the
life of the instance. configure replaces the config on every update, but the
W3C-pointer hover closures kept calling the callbacks captured when the handlers
were first created, so a hover callback that closes over component state observed
that state as it was at mount, for the life of the view, however many times the
component re-rendered.

Every other handler in _createEventHandlers already reads this._config inside
its own body, and so does the legacy mouse branch below. This makes the W3C
pointer branch do the same. It also restores reset's documented guarantee for
hover: after reset freezes this._config, a late onPointerEnter no longer
calls a configured callback.

Whether to attach onPointerEnter/onPointerLeave at all is still decided once,
from the config present when the handlers are created, because that presence is
what makes the host view listen for pointer enter/leave. A view that mounts
without a hover callback and is given one later still does not begin listening.
That behaviour is unchanged by this diff.

Only the branch behind shouldPressibilityUseW3CPointerEventsForHover is
touched. With that flag at its default the generated handlers are byte-identical
to before.

Changelog:
[General][Fixed] - Pressability now invokes the current onHoverIn/onHoverOut rather than the ones captured when its event handlers were created

Differential Revision: D126767220

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 22, 2026
@rozele
rozele force-pushed the export-D126767220 branch from b3290b4 to 14924d0 Compare October 22, 2026 14:04
@meta-codesync

meta-codesync Bot commented Oct 22, 2026

Copy link
Copy Markdown

@rozele has exported this pull request. If you are a Meta employee, you can view the originating Diff in D126767220.

…eact#59363)

Summary:
Pull Request resolved: react#59363

`Pressability._createEventHandlers` destructured `onHoverIn`/`onHoverOut` out of
`this._config` once, and `getEventHandlers` memoises the handler object for the
life of the instance. `configure` replaces the config on every update, but the
W3C-pointer hover closures kept calling the callbacks captured when the handlers
were first created, so a hover callback that closes over component state observed
that state as it was at mount, for the life of the view, however many times the
component re-rendered.

Every other handler in `_createEventHandlers` already reads `this._config` inside
its own body, and so does the legacy mouse branch below. This makes the W3C
pointer branch do the same. It also restores `reset`'s documented guarantee for
hover: after `reset` freezes `this._config`, a late `onPointerEnter` no longer
calls a configured callback.

Whether to attach `onPointerEnter`/`onPointerLeave` at all is still decided once,
from the config present when the handlers are created, because that presence is
what makes the host view listen for pointer enter/leave. A view that mounts
without a hover callback and is given one later still does not begin listening.
That behaviour is unchanged by this diff.

Only the branch behind `shouldPressibilityUseW3CPointerEventsForHover` is
touched. With that flag at its default the generated handlers are byte-identical
to before.

Changelog:
[General][Fixed] - `Pressability` now invokes the current `onHoverIn`/`onHoverOut` rather than the ones captured when its event handlers were created

Differential Revision: D126767220
@rozele
rozele force-pushed the export-D126767220 branch from 14924d0 to b78ca52 Compare October 22, 2026 14:09
@meta-codesync meta-codesync Bot changed the title Read hover callbacks from the live Pressability config at invocation Read hover callbacks from the live Pressability config at invocation (#59363) Oct 22, 2026
@meta-codesync meta-codesync Bot closed this in 8a4cf38 Oct 22, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @rozele in 8a4cf38

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants