Skip to content
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

Ignore clicks on scrollbars #9

Closed
Rodeoclash opened this issue Sep 8, 2016 · 8 comments
Closed

Ignore clicks on scrollbars #9

Rodeoclash opened this issue Sep 8, 2016 · 8 comments

Comments

@Rodeoclash
Copy link

Great plugin. One problem, clicking and dragging the scrollbar causes the document click event to fire. I know right? Who uses scrollbars and not the wheel...

I'm happy to PR this but wanted to discuss first how to handle it. It doesn't seem like theirs a way to nativly detect when a document click originates from a scrollbar without additional work measuring screen dimensions.

Thoughts?

@kentor
Copy link
Owner

kentor commented Sep 8, 2016

When is that an issue? When you need to scroll to see the content in the dropdown?

@Rodeoclash
Copy link
Author

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.

@Rodeoclash
Copy link
Author

I can put together a video if that helps visualise what's going on.

@kentor
Copy link
Owner

kentor commented Sep 8, 2016

Yes please. What OS/Browser are you using? Doesn't happen to me on OS X Yosemite, Chrome

@Rodeoclash
Copy link
Author

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.

https://youtu.be/rVA6F9hFgM4

@kentor
Copy link
Owner

kentor commented Sep 8, 2016

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.

http://stackoverflow.com/questions/25349259/should-a-click-handler-be-run-when-clicking-on-a-scrollbar

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.

@Rodeoclash
Copy link
Author

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.

@levitomer
Copy link

levitomer commented Feb 11, 2019

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants