Control popover by hovering and outside interactions #6563
-
This discussion talks about controlling a popover by hovering using the However, doing that makes it so that we loose:
Here is the sample code for reference <div
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
className="flex justify-center"
>
<DialogTrigger>
<Button
onPress={() => setHover(!hover)} <Popover
isOpen={hover} Note that the onPress above did not help for touch screens, probably because pressing and hovering overlap. With iPad mini's having large resolutions, it's hard to tell if we are on a computer or touch only environment and resolution based rendering will not help us here. I know that the component by default has a lot of the accessibility taken care of, so I am a bit concerned of using this as a controlled component since I probably loose all of that, just to make it open with hover. Could we use the TooltipTrigger in combination with the DialogTrigger to get the benefits of both hover and the built in accessibility functionality? Summary of Questions
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
There's no such thing as hover on a touch screen. This is why tooltips are not accessible. Checking screen resolution is not a reliable way to check if the environment is touch only, as you've noted, and there isn't any way to determine this as of the time of writing this. People can connect a keyboard to an iPad for instance, or they may be using VoiceOver. I'm guessing the onPress isn't firing on the button in the dialog trigger because there is an underlay. You may have to do more work to hook up events to support this. Overall it's not recommended because hover isn't an accessible pattern. |
Beta Was this translation helpful? Give feedback.
There's no such thing as hover on a touch screen. This is why tooltips are not accessible. Checking screen resolution is not a reliable way to check if the environment is touch only, as you've noted, and there isn't any way to determine this as of the time of writing this. People can connect a keyboard to an iPad for instance, or they may be using VoiceOver.
I'm guessing the onPress isn't firing on the button in the dialog trigger because there is an underlay. You may have to do more work to hook up events to support this. Overall it's not recommended because hover isn't an accessible pattern.