-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow nested Pressables to bubble their hover state to parent pressables #1875
Comments
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. |
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. |
My issue is basically this: <Pressable testID="menu" onHoverOut={hideMenu}>
<Pressable testID="trigger" onHoverIn={showMenu} />
<Dropdown />
</Pressable> Except that I want to use |
A friendly ping to draw attention to a problem. |
I think tooltips got broken in Expo 49, probably the react-native-web version getting bumped. There's an existing bug for why we can't have nested Pressables. The fun thing was if you got your mouse into the corner of an IconButton (IconButtons are round, the surrounding Pressable is square), you'd get a tooltip, but as soon as you entered the child Pressable, the tooltip was cleared. So to fix it, use the new onPointer* events on View from React Native. These are added since Android and iOS devices can now have mice, styluses, etc and mobile should support them too. So in our implementation, we allow tooltips on hover on all 3 platforms, though normal mobile device still won't get them (because you can't hover with touch). necolas/react-native-web#1875
I think tooltips got broken in Expo 49, probably the react-native-web version getting bumped. There's an existing bug for why we can't have nested Pressables. The fun thing was if you got your mouse into the corner of an IconButton (IconButtons are round, the surrounding Pressable is square), you'd get a tooltip, but as soon as you entered the child Pressable, the tooltip was cleared. So to fix it, use the new onPointer* events on View from React Native. These are added since Android and iOS devices can now have mice, styluses, etc and mobile should support them too. So in our implementation, we allow tooltips on hover on all 3 platforms, though normal mobile device still won't get them (because you can't hover with touch). necolas/react-native-web#1875
I think tooltips got broken in Expo 49, probably the react-native-web version getting bumped. There's an existing bug for why we can't have nested Pressables. The fun thing was if you got your mouse into the corner of an IconButton (IconButtons are round, the surrounding Pressable is square), you'd get a tooltip, but as soon as you entered the child Pressable, the tooltip was cleared. So to fix it, use the new onPointer* events on View from React Native. These are added since Android and iOS devices can now have mice, styluses, etc and mobile should support them too. So in our implementation, we allow tooltips on hover on all 3 platforms, though normal mobile device still won't get them (because you can't hover with touch). necolas/react-native-web#1875
Is your feature request related to a problem? Please describe.
When you have a nested
Pressable
contained within anotherPressable
, the hover state of the innerPressable
cannot easily be shared with the parentPressable
. 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 asshouldBubbleHoverState
, 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!
The text was updated successfully, but these errors were encountered: