question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using safePolygon in useHover handleClose prevents clicks on outside elements from working

See original GitHub issue

When 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:closed
  • Created a year ago
  • Comments:20 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
atomikscommented, Jul 25, 2022

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 local

1reaction
atomikscommented, Jul 25, 2022

SafePolygon 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 even body { pointer-events: initial !important } if you don’t care about pointer-events when testing anywhere else. Or fire a pointermove event outside of the polygon area, simulating a real user.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found