Comments (8)
Hi
I was introduced to this annoying issue today, I found that using offsetX together with clientWidth did the job and the solution is pretty straight forward:
if (e.offsetX <= e.target.clientWidth) { onClickOutsideEvent(e); }
Hope this helps someone 👍
from react-click-outside.
When is that an issue? When you need to scroll to see the content in the dropdown?
from react-click-outside.
Say I have a dropdown menu on a sticky header. It's possible to open that menu then expect to be able to scroll the page under the header without it closing the menu.
from react-click-outside.
I can put together a video if that helps visualise what's going on.
from react-click-outside.
Yes please. What OS/Browser are you using? Doesn't happen to me on OS X Yosemite, Chrome
from react-click-outside.
I'm on Ubuntu / Chromium and see it, was reported on Safari / Yosemite I think. Could be Chrome / Yosemite.
Here's an example. You'll see I demonstrate the floating header /w content scrolling under it. Then it closing on mouse down on the scrollbar. Some examples of document click closing it (as it should) then the scrollbar closing it again.
from react-click-outside.
Does not close the dropdown for me on Safari 9.
From google searching it seems like there's no spec whether clicking on the scroll bar should trigger a click event. And perhaps some browsers do and some browsers don't.
https://bugs.chromium.org/p/chromium/issues/detail?id=6759 (issue with blurring of focused element, but could be the same underlying problem)
I guess we can see what solutions other people have come up with.
from react-click-outside.
Ah edge cases huh. I'll discuss with the team here about what they want to do, perhaps we might be able to work around it. If we go ahead with fixing it, I'll put a PR together.
from react-click-outside.
Related Issues (20)
- Does position of component affect handleClickOutsided handler? HOT 1
- Click outside event triggers even when the component is hidden or when set to display:none? HOT 2
- Unable to find node on an unmounted component in React 16.0.0 HOT 2
- This wrapper broke the prototype chain in inheritance HOT 4
- Doesn't work if you click outside, over an iFrame HOT 1
- Element.closest() support? HOT 1
- How to wrap stateless component with react-click-outside? HOT 2
- feature request- className for ignored components HOT 1
- handleClickOutside not working in iPhone6 [BUG]. HOT 1
- Make react-click-outside event listener configurable so that it can be attached to event bubbling phase rather than capturing phase. HOT 4
- Please add a change log HOT 1
- TypeError: hoistNonReactStatic is not a function HOT 2
- IE11
- Add exception HOT 1
- Server side support HOT 1
- Warnings with React StrictMode HOT 1
- Add ability to work with react hooks
- Click and drag initiated from inside popover still closes it
- Defunct with parcel, babel 7
- react-click-outside breaks TypeScript suggestions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-click-outside.