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

Dragging the scroll bar to scroll does not work. #139

Closed
spivurno opened this issue Apr 18, 2020 · 16 comments
Closed

Dragging the scroll bar to scroll does not work. #139

spivurno opened this issue Apr 18, 2020 · 16 comments

Comments

@spivurno
Copy link

Summary

Clicking and dragging the scrollbar to scroll through a modal that is taller than the viewport does not work. Interestingly, scrolling via a scroll wheel or trackpad does work.

Steps to Recreate

  1. Open https://tingle.robinparisi.com/
  2. Click the "Big Content? No problem!" demo button.
  3. Ensure that your browser window is smaller than the modal so that scrolling is required.
  4. Attempt to click and drag the scrollbar. The result differs depending on OS and browser. Here are the results from my testing.

Mac | Firefox: Clicking the scrollbar closes the modal.
Mac | Chrome: Clicking the scrollbar closes the modal.
Mac | Safari: Clicking the scrollbar closes the modal.

The following were tested with BrowserStack:

Windows | Firefox: Works!
Windows | Chrome: The scrollbar does not move.
Windows | Safari: Couldn't get the site to load...
Windows | IE11: Works!
Windows | Edge: The scrollbar does not move.


Eager to be helpful. I'd be happy to commission or provide some additional sponsorship for your attention to this issue. I really appreciate your time!

@emmanuelballery
Copy link

Hello,

The rule .tingle-modal:before used to add a backdrop filter blur is in a fixed position and is rendered in front of the scrollbar ;

tingle/src/tingle.css

Lines 248 to 262 in 4e4237a

@supports (backdrop-filter: blur(12px)) {
.tingle-modal:before {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
content: "";
backdrop-filter: blur(18px);
}
.tingle-enabled .tingle-content-wrapper {
filter: none;
}
}

This is only the case when backdrop-filter is supported hence the strange browsers behaviors.

I think you can use an absolute positioning instead of a fixed one to avoid this bug (as its parent is already fixed) :

@supports (backdrop-filter: blur(12px)) {
  .tingle-modal:before {
    position: absolute;
  }
}

@spivurno
Copy link
Author

Hi @emmanuelballery, thank you! This solves the issue in both Windows Chrome and Windows Edge.

Do you have any insights into how this might be addressed in the Mac browsers? I tried your fix there without success. I tried disabling the ::before backdrop completely. Still no love. I suspect the issue may have to do with the click event being picked up by Tingle.

@emmanuelballery
Copy link

Hello,

This is the list of browsers I worked with :

  • [no bug] do not support backdrop-filter :

    • Linux > Chrome 73.0.3683.86
    • Linux > Firefox 75.0
    • Windows (VM) > Firefox 75.0
    • Windows (VM) > IE 11.615.17763.0
    • Mac (VM) > Firefox 75.0
  • [bug] support backdrop-filter, scrollbar is not accessible :

    • Windows (VM) > Chrome 81.0.4044.113
    • Windows (VM) > Edge 44.17763.1.0
    • Windows (VM) > Opera 67.0.3575.137
    • Mac (VM) > Chrome 81.0.4044.113
    • Mac (VM) > Safari 11.0

  1. Applying absolute positioning instead of a fixed one to .tingle-modal:before is not a solution (sorry), it will limit the size of the backdrop ; when scrolling it's noticible ; display: none; is the solution for now ;

Capture du 2020-04-21 09-47-54

  1. In Safari the scrollbar is not rendering, even when preference is set to always :

Capture du 2020-04-21 10-08-10

I tried to hack the scrollbar using this StackOverflow answer : https://stackoverflow.com/a/7855592

.tingle-modal::-webkit-scrollbar {
  -webkit-appearance: none;
}
.tingle-modal::-webkit-scrollbar:vertical {
  width: 10px;
}
.tingle-modal::-webkit-scrollbar-thumb {
  border: 2px solid white;
  background-color: black;
}
.tingle-modal::-webkit-scrollbar-track {
  background-color: #ffffff;
}

It works. It is usable. But, what a hack ...

Capture du 2020-04-21 10-21-49


I don't think I can do more. A new DOM node to handle this blur backdrop would probably be the best solution.

@robinparisi
Copy link
Owner

robinparisi commented Apr 24, 2020

It's a tricky one...

We should be able to calculate scrollbar width then adapt event listener to handle click on scrollbar by using this:

var scrollbarWidth = this.modal.offsetWidth - this.modal.clientWidth

But on MacOS, depending on the setting shown by @emmanuelballery, the browser won't return the correct size when the scrollbar is set to "When scrolling" or when using Safari.

We could use this data as a workaround but I find it a bit hacky:

https://codepen.io/sambible/post/browser-scrollbar-widths

To be honest, I don't understand why scrollbar trigger click event. It should be a different DOM elem or trigger a different event...

Edit: another ressource

@emmanuelballery
Copy link

Hi @robinparisi,

The real problem is this rule .tingle-modal:before which displays an invisible block in front of the scrollbar (a fixed block in a fixed block). The click event is not triggered by the scrollbar, but by the :before rendered in front of it. Hiding/removing this :before fixes everything;

This issue started here 21e333c.

The blur effect is fine when using the tingle-content-wrapper class as written in the doc:

Important: For the blur effect, you need to wrap your content inside a container with the "tingle-content-wrapper" class.

@emmanuelballery
Copy link

A solution could be to add a parent to .tingle-modal with this blur effet. Something like:

.tingle-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  backdrop-filter: blur(18px);
  & > .tingle-modal {
    position: relative;
    height: 100%;
    overflow-y: auto;
    // remove top, right, bottom, left, z-index rules
  }
}

@robinparisi
Copy link
Owner

robinparisi commented Apr 28, 2020

@emmanuelballery Maybe I'm missing something but I think we're talking about two different problems.

With the following setting:

Capture d’écran 2020-04-28 à 04 51 07

  • with pseudo-element:
    • ❌ Firefox: click on the scrollbar trigger event and close modal
    • ❌ Chrome: click on the scrollbar trigger event and close modal
  • without pseudo-element (by completely removing the code):
    • ❌ Firefox: click on the scrollbar still trigger event and close modal
    • ❌ Crome: click on the scrollbar still trigger event and close modal

So even without the pseudo element, scrollbar trigger an event but it shouldn't. In fact, this seems logic because in theory, pseudo-element aren't part of the DOM and we can't attach events to them.

With this setting instead:

Capture d’écran 2020-04-28 à 04 55 25

  • with pseudo-element:
    • ✅ Firefox: click on the scrollbar works
    • ⚠️ Chrome: can't use scrollbar because of the pseudo-element but we can use pointer-event: none to fix this easely
  • without pseudo-element:
    • ✅ Firefox: click on the scrollbar works
    • ✅ Crome: click on the scrollbar works

macOS version: 10.14.6

@robinparisi
Copy link
Owner

robinparisi commented Apr 28, 2020

If I resume, we have 3 bugs:

  • scrollbar shouldn't trigger close event on OSX (depending on macOS version, browser and scroll settings)
  • when working as expected, pseudo-element :before souldn't prevent scroll (easy fix with pointer-event: none)
  • on Safari, when scrollbar is set to "Always" in general settings, the scrollbar on tingle-modal div doesn't even appears (I try your custom CSS @emmanuelballery but it doesn't work for me)

@emmanuelballery
Copy link

Man, I always forget about pointer-events! My custom CSS was just a mockup, not an actual implementation, sorry 🤦

I think there are only 2 bugs. One you just fixed with pointer-events: none;. The other one being Safari not wanting to show the scrollbar at all (but is it really tingle's problem ...).

# nothing wrong, do not support "backdrop-filter"
# Linux > Chrome 73.0.3683.86
# Linux > Firefox 75.0
# Windows (VM) > Firefox 75.0
# Windows (VM) > IE 11.615.17763.0
# Mac (VM) > Firefox 75.0

+ support "backdrop-filter" but fixed with "pointer-events: none"
+ Windows (VM) > Chrome 81.0.4044.113
+ Windows (VM) > Opera 67.0.3575.137
+ Mac (VM) > Chrome 81.0.4044.113

! support "backdrop-filter" but the scrollbar is blurry even with "pointer-events: none"
! Windows (VM) > Edge 44.17763.1.0

- no scrollbar at all, even with general settings set to "always show"
- Mac (VM) > Safari 11.0

@robinparisi
Copy link
Owner

robinparisi commented Apr 28, 2020

If I assume the following:

  • clone master branch
  • add pointer-events: none; to .tingle-modal:before in tingle.css
  • serve demo with gulp watch
  • macOS version: 10.14.6
  • macOS : Settings > General > Show scrollbar > "When scrolling" (important)
  • Firefox 75.0 or Chrome 81.0
  • open "Big content ?" example

I use trackpad and start scrolling, scrollbar then appears, I try to click on scrollbar to scroll by dragging it -> trigger event and close the modal

If @spivurno can confirm because the only diff I see with @emmanuelballery is that I use a native version and not a VM (and maybe our OS version are not the same, the auto scrollbar is typically an OS dependent behavior).

@spivurno
Copy link
Author

I can confirm that the pointer-events: none; solution fixes the issue where the scrollbar was not clickable in all of the Windows browsers.

With the same fix in place, I am still seeing the issue on Mac browsers. Starting to scroll reveals the scrollbar and then clicking the scrollbar closes the modal (rather than allowing you to drag it).

If you update the macOS Show scrollbar setting to "Always", the point-events: none; solution does resolve the issue on Mac browsers as well (except the noted issue about Safari which does not show the scrollbar at all).

@robinparisi
Copy link
Owner

Ok for me this is a problem on how macOS inject the automatic scrollbar into the DOM. I have some ideas on how to try to correct this but it is not ideal since we can't detect properly scrollbar mode, usage mode (touch, mouse, trackpad) and browser.

I will think a little more and I will implement what seems the less "hacky".

@robinparisi
Copy link
Owner

It should be good with the lastest release (v0.15.3)

@emmanuelballery
Copy link

Seems like you had a great night! Thanks!

@spivurno
Copy link
Author

spivurno commented May 2, 2020

@robinparisi Thank you so much! Implemented and tested. Works great! Sent you a few coffees via Ko-fi.

@emmanuelballery I'd love to buy you a cup a coffee. Any method for doing so?

@emmanuelballery
Copy link

That's really nice of you @spivurno. Just reward @robinparisi! He was the one who did all the work. I also had an interest in fixing this issue for my clients!

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

No branches or pull requests

3 participants