Skip to content

Pressable: outer onHoverIn fires when the pointer leaves a nested Pressable and the outer Pressable together #2947

Closed

Description

@raajnadar

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

Pressable calls useHover with contain: true. When the pointer enters an inner Pressable, the outer one gets onHoverOut, which is expected. When the pointer leaves the inner one, the "unlock" listener calls hoverStart on the outer one. This also occurs when the pointer leaves the outer one in the same move, for example when an overlay opens under a still pointer.

<Pressable onHoverIn={...} onHoverOut={...}>   {/* outer */}
  <Pressable><Text>Inner</Text></Pressable>
</Pressable>

Expected behavior

The outer Pressable gets no onHoverIn after the pointer leaves it. When the pointer enters the inner Pressable, the outer hover ends (contain: true). When the pointer then leaves both Pressables, the outer hover stays ended.

The expected log for Case A:

outer onHoverIn   (event: pointerenter)
outer onHoverOut  (event: pointerenter)

The expected log for Case B is the same, plus inner onPress: the overlay opens.

Steps to reproduce

Case A, a pointer move:

  1. Open the Snack and select the Web preview.
  2. Click Clear the log.
  3. Move the mouse pointer onto the blue box ("Inner Pressable").
  4. Move the pointer off the blue box onto the white page, in one move. The inner box fills the outer Pressable, so this move leaves both.
  5. Read the log.

Case B, an overlay that opens under a still pointer:

  1. Click Clear the log.
  2. Move the mouse pointer onto the blue box.
  3. Click the blue box. Do not move the pointer. An overlay opens under the pointer.
  4. If the log shows no new line, move the pointer one pixel.
  5. Read the log.

Test case

https://snack.expo.dev/@raajnadar/react-native-web-pressable-bug

Additional comments

Possible fix: in the unlock listener, start the outer hover again only when the pointer is still inside the outer element

Activity

  1. raajnadar commented on Nov 2, 2026

    @raajnadar
    Author

    Actual behaviour (react-native-web 0.21.4)

    Case A: the pointer moves off the blue box onto the page:

    703221 ms outer onHoverIn (event: pointerenter)
    703222 ms outer onHoverOut (event: pointerenter)
    705438 ms outer onHoverIn (event: pointerenter) ← the pointer has already left the outer Pressable
    705438 ms outer onHoverOut (event: pointerleave)

    Case B, the overlay opens under a pointer that does not move:

    769270 ms outer onHoverIn (event: pointerenter)
    769271 ms outer onHoverOut (event: pointerenter)
    770696 ms inner onPress: the overlay opens
    770711 ms outer onHoverIn (event: pointerenter) ← 15 ms after the press, with no pointer move
    770711 ms outer onHoverOut (event: pointerleave)

    In both cases, the extra onHoverIn has the same timestamp as the next onHoverOut. Both calls come in one event dispatch, before React renders. So a handler that reads the current state in onHoverOut still sees the state from before the onHoverIn. The extra onHoverIn also gets the old pointerenter event from the first hover, not a new event.

    Not a duplicate of #1875. This issue does not ask to share hover state with a parent. The contain: true behaviour can stay. The defect is only the extra onHoverIn after the pointer leaves the outer Pressable.

  2. added a commit that references this issue on Nov 6, 2026
    d5f39d7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions