react-native-web icon indicating copy to clipboard operation
react-native-web copied to clipboard

Allow nested Pressables to bubble their hover state to parent pressables

Open roryabraham opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe. When you have a nested Pressable contained within another Pressable, the hover state of the inner Pressable cannot easily be shared with the parent Pressable. I encountered this problem when trying to make a menu that displays when an element is hovered over.

This code sandbox illustrates the problem I'm having.

Describe a solution you'd like I understand that this isn't always the desired behavior, so perhaps just adding a boolean prop to the Pressable component such as shouldBubbleHoverState, would do the trick.

Describe alternatives you've considered A temporary workaround is to use a <TouchableOpacity /> instead of a <Pressable /> for the nested element. This has some limitations, however, and would not allow the nested element to take advantage of hoverability too.

Happy to chat some more if you have ideas, need clarification, or can think of other workarounds in the meantime. Thanks!

roryabraham avatar Jan 14 '21 01:01 roryabraham

I found a workaround that seems to work for me. Use a custom Hoverable for the wrapper and then Pressable for the children. Still think this could be a useful feature.

roryabraham avatar Jan 14 '21 14:01 roryabraham

I'm facing the exact same issue. I'd like to use RNW's Pressable, but I suppose I'll rely on a userland solution for now.

nandorojo avatar Aug 29 '21 20:08 nandorojo

My issue is basically this:

<Pressable testID="menu" onHoverOut={hideMenu}>
  <Pressable testID="trigger" onHoverIn={showMenu} />
  <Dropdown />
</Pressable>

Except that I want to use onHoverIn/onHoverOut from both the child and parent Pressables.

nandorojo avatar Aug 29 '21 20:08 nandorojo

A friendly ping to draw attention to a problem.

luixo avatar Mar 22 '23 01:03 luixo