Using safePolygon in useHover handleClose prevents clicks on outside elements from working
See original GitHub issueWhen using safePolygon in the useHover hook to allow interactive contents in Tooltips, that will prevent the first outside click from working, as the hook adds pointer-events: none;
to everything else. This is very evident when setting the close delay to a large time.
useHover(context, {
handleClose: safePolygon(),
delay: {
close: 5000
}
}),
Reproduction: https://codesandbox.io/s/epic-murdock-g3s412?file=/src/Tooltip.tsx
In there, hover over the button to show the Tooltip, then try to click the link below the button. The first click never works while the Tooltip is still open.
Issue Analytics
- State:
- Created a year ago
- Comments:20 (4 by maintainers)
Top Results From Across the Web
useHover
The package exports a safePolygon() handler which will only close the floating element if the pointer is outside a dynamically computed polygon area....
Read more >Detecting click outside React component and single state ...
I wanted help with two things. Closing the modals on outside clicks!, and. The hover element is slow because it has three states,...
Read more >Using safePolygon in useHover handleClose prevents clicks on ...
When using safePolygon in the useHover hook to allow interactive contents in Tooltips, that will prevent the first outside click from working, ...
Read more >How to detect a click outside of a React Component (16.8+)
Blog post coming soon w/ code snippetsOur Blog: https://picnature.de/en/blog/Get Elementor Pro: ...
Read more >Detect Outside Click for Any Element in ReactJS - YouTube
Detect outside click in React JS. Consider a simple div or any element in React JS. We can use onClick to add click...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep we should track it. I also noticed macOS’ auto-hiding scrollbars appear when a scrolling element has
pointer-events: none
put on it in Chrome (doesn’t happen in FF/Safari). SafePolygon would have none of these unforseen side effects since it’s localSafePolygon would solve all the issues yes, I think that’s the best solution.
By disabling the check, you mean remove the test? You can add a
#root, #floating-ui-root { pointer-events: initial; }
on the React root/portaled roots for now. Or evenbody { pointer-events: initial !important }
if you don’t care about pointer-events when testing anywhere else. Or fire apointermove
event outside of the polygon area, simulating a real user.