OverlayScrollbars icon indicating copy to clipboard operation
OverlayScrollbars copied to clipboard

autohide: leave requires double tap on touch devices

Open itshallrun opened this issue 5 years ago • 14 comments

Hey,

I am working on a cross plattform web app. The issue is, on touch devices, the autoHide: "leave" option requires a double tap to trigger the touch event. The first tap will show the scrollbar, and the second tap will actually trigger the touch event underneath.

touchSupport is active in my options.

                    resize: "none",
                    sizeAutoCapable: true,
                    paddingAbsolute: true,
                    scrollbars: {
                        visibility: "auto",
                        autoHide: "leave",
                        autoHideDelay: 400,
                        dragScrolling: true,
                        clickScrolling: false,
                        touchSupport: true,
                    },

Is there any way to have autoHide: "leave" for non-mobile devices and trigger the touch event on the first tap on mobile?

itshallrun avatar Dec 02 '20 16:12 itshallrun

Good day! @itshallrun

With "trigger the touch event on the first tap" you mean the possibility to scroll, or the possibility to interact with the scrollbars?

KingSora avatar Dec 02 '20 18:12 KingSora

I mean, if there are some elements in a scrollable container, then the first tap will show the scrollbars (which are hidden by default) and the second tap will trigger the onClick / touch event of the touched element. So the scrollbars are kind of blocking the content from being triggered on the first tap.

itshallrun avatar Dec 02 '20 18:12 itshallrun

Alright.. The touched elements are they below the actual scrollbars, or does the position of the element doesn't matter?

What OS, device and browser are you using? Does this only happen with the autohide: leave option? Can you trigger it also on desktop devices somehow?

KingSora avatar Dec 02 '20 19:12 KingSora

I am using the react version. I could test it on an Ipad pro. It is an issue for autohide:leave only. The position doesn't matter. Whenever I tap in the Scrollbars container, the first tap always triggers the visibility of the scrollbars. On the desktop, the behavior is as desired. The scrollbars are hidden until the scrollbars container is hovered. And they disappear when the container is left.

itshallrun avatar Dec 02 '20 19:12 itshallrun

@itshallrun alright, I'll take a look into it as soon as I have time.. I don't have a iPad, so I'll need some time to find a way to reproduce it

KingSora avatar Dec 10 '20 22:12 KingSora

Hello KingSora,

Thanks for great library!

I tested it very thoroughly on the iPhone.

I confirm that this is a problem when using on iOS.

Please review and fix it when possible!

Best Regards!

beeteam368 avatar Dec 11 '20 03:12 beeteam368

@beeteam368 I'll give my best :)

KingSora avatar Dec 11 '20 07:12 KingSora

@beeteam368 I'll give my best :)

Thanks! Wish you a good day!

beeteam368 avatar Dec 14 '20 02:12 beeteam368

@KingSora hello mr king. is there any progress on this issue? this still occurs on iOS

theo-staizen avatar Oct 25 '21 07:10 theo-staizen

@theo-staizen I have it on my backlog, but I couldn't reproduce it until now.. is it possible to create an video or something like that?

KingSora avatar Oct 25 '21 07:10 KingSora

I'll get something to you asap (the page we have is under NDA, so I'm trying to make a clean example). Btw you should be able to request free browserstack access for this project: https://www.browserstack.com/open-source for you to be able to test on devices you dont own. it's better than nothing :)

theo-staizen avatar Oct 25 '21 07:10 theo-staizen

@theo-staizen thanks a lot! I've tried it with browserstack already (btw. huge thanks to them, many bugs could be only solved cause of that), but I still wasn't able to get the described problem..

KingSora avatar Oct 25 '21 12:10 KingSora

@KingSora I spent a bit more time setting it up a codesandbox, but the problem seems to be intermittent and only happens under these conditions:

  • Only happens under React, which makes me believe it is caused by React's synthetic events.
  • Only happens when the scroll container (or window) loses focus

I'll keep trying to get this consistently failing

theo-staizen avatar Oct 25 '21 12:10 theo-staizen

@theo-staizen thanks a lot! :)

KingSora avatar Oct 27 '21 12:10 KingSora

Can you please try v2 and confirm whether this issue still persists? :)

KingSora avatar Nov 12 '22 13:11 KingSora

Yes, I confirm that the issue is still present on 2.1.0.

The first touch displays the current scroll, and the second lets you click on the link.

alvarolb avatar Feb 27 '23 12:02 alvarolb

@alvarolb thanks for the update, do you mind creating an minimal reproducable example with which I could try to solve the issue? :)

KingSora avatar Feb 27 '23 15:02 KingSora

Hi there. First off @KingSora - loving your work!

Just to add to this - I've also just hit the same problem and came across this page looking for a solution. My guess is that it's down to the fact that iOS doesn't like hovers. Anything with a hover effect on it needs a double tap in iOS, and I assume you have a hover somewhere looking for the mouse hover on auto hide.

Anyway - I hacked a work-around to get me going - at least for now. No idea if it's any good, but it only took 2 mins and it seems to work.

I installed react-device-detect (something I have used before) and then created a new component that uses the fact that you are on a mobile device to skip using OverlayScrollbars. The scrollbars do what I want them to do on iOS out of the box anyway.

Kinda like this:

import { isMobile } from 'react-device-detect';

function ScrollWrapper({ children }) {

  if (isMobile) {
    return children
  } else {
    return (
      <OverlayScrollbarsComponent
        options={{ scrollbars: { autoHide: 'leave', autoHideDelay: 500 } }}
      >
        {children}
      </OverlayScrollbarsComponent>
    )
  }
}

Once you have the above, replace where you had the OverlayScrollbarsComponent with ScrollWrapper in your original code.

I hope that makes sense.

robwheatley avatar Apr 05 '23 16:04 robwheatley

@robwheatley Thanks for posting your solution :)

Just for completeness I would like to add that this solution could cause problems with server side rendering

KingSora avatar Apr 06 '23 08:04 KingSora

@KingSora Thanks for the heads-up. In my case, I don't need to worry as I'm not doing any SSR ;-). Worth noting though.

robwheatley avatar Apr 06 '23 10:04 robwheatley

This issue should be fixed in version v2.3.1.

KingSora avatar Sep 17 '23 10:09 KingSora