Prevent clicks when dropping scrollbar handle
See original GitHub issueDescribe the bug Wasn’t sure if I should raise this as a bug report or a feature request.
When the overlay scrollbar handle is dropped, a click event also fires. I think this is different from native scrollbars (I believe) and is undesired in most cases I think.
Let’s say I have a list of items, like a playlist on Spotify. You can select tracks in the playlist by clicking on them. If I now drag the overlay scrollbar and release it either on top of body
or on top of the handle itself, a click event is also fired. The playlist is built to clear selection of it’s tracks when a user clicks outside of the playlist. This is a common pattern and often used to close modals when a user clicks outside:
// Inside some component
document.body.addEventListener(('click') => {
// did click happen outside me?
// if yes, do some state clean-up (like closing modal or clearing selection)
})
In our case I worked around this by disabling pointer-events on body
and the handle while it’s being dragged.
// Prevent clicks on body and scrollbar handle when dragging and dropping the handle.
// We for example don't want to clear the selected tracks in a playlist when
// the scrollbar handle is dropped. The .os-dragging class is only applied
// while the overlay scrollbars are being dragged with the mouse.
.os-dragging,
.os-dragging .os-scrollbar-handle {
pointer-events: none !important;
}
Happy to fill in a js-fiddle and the rest of the steps in the template later if this is not clear enough. I don’t have time right now
To Reproduce Steps to reproduce the behavior:
- Go to ‘…’
- Click on ‘…’
- Scroll down to ‘…’
- See error
Expected behavior A clear and concise description of what you expected to happen.
Examples Please create a small example of the bug. To do this you can use online platforms like JSFiddle, CodeSandbox or StackBlitz. You can also create a separate Github repository which I can clone.
Environment
- Used Operating System(s):
- Used Browser(s) (with version):
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Just tested this in 1.13.0, works great. Thanks!
Implemented in v1.13.0.