-
Notifications
You must be signed in to change notification settings - Fork 65
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
Event should not trigger on clicking browser scrollbar #19
Comments
I’m not sure what you mean - scrolling certainly shouldn’t trigger a click, since the scroll bar is entirely outside of the viewport (it’s not a DOM element). Can you provide a repro case? |
@ljharb, |
right - i'm surprised to hear that clicking on any part of the scrollbar would create a click event. That's not been my experience. Can you provide a repro case? |
I somewhat vaguely remember that back in the day adding click handler to |
I have this same issue that I experienced when using react-dates. Here is a repo case: http://airbnb.io/react-dates. For the default date range picker, clicking the scroll bar closes the date range picker with a mouse down / mouse up event on the entire document. A similar issue existed in bootstrap for modals closing on mouse down. twbs/bootstrap#14263. It seems like scroll bars receive a mouse down / mouse up event, but not a click event. |
If this is a browser bug, then the only way we can get around it is if there’s a way to determine that the event was generated from clicking on the scrollbar. If there is, then this can be fixed; if not, not. |
The only way I can guess is to check if the event.target is the html tag (the entire document) or if the parent element is undefined. Specifically this line in the onMouseDown function:
Alternatively, addEventListener calls could be updated to listen on document.body, which should also prevent the scrollbar target from intercepting. I changed the code locally, and both options worked for me. |
Hmm - if in fact that's the case (that the target can't ever be the html tag except in this case), and we can verify that in all supported browsers, then that seems like a good approach. It doesn't seem like a good idea to install more event listeners on the body. |
No description provided.
The text was updated successfully, but these errors were encountered: