iOS 15 overflow issue for fixed elements when Tab Bar is positioned top

Viewed 1444

iOS 15 appears to have an issue with overflowing fixed elements when the Tab Bar is positioned at the top instead of the bottom (the new default).

For example, I have a long Bootstrap 5 Modal which has buttons at the bottom so the user scrolls within the modal which hides Safaris UI and then when trying to click the button iOS, instead, forces Safari's UI back into view making the button inaccessible. See the gif example below (appologies for low quality, there's a file size limit)...

enter image description here

In the gif above you can see Safari's UI jumping in and out as I scroll and tap the 'Close' button.

View the example here: https://thelevicole.com/ios-15-overflow-issue/

Example code here: https://github.com/thelevicole/ios-15-overflow-issue/blob/main/index.html

I found a similar issue here: iOS 15 safari toolbar now hides when scrolling within an element which the comments link to an Apple video highlighting the use of CSS env variables so I've tried adding the safe area inset to the top and bottom of the modal...

.modal {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

This does not appear to have any affect.

Please note that my example isn't the only time this issue occurs, I've ran into the same issue on almost every site that has an overflowing fixed element (i.e. cookie preferences etc).

Is there a solution or is this a bug that should be submitted to Apple?

2 Answers

I solved this problem for my case. Perhaps it will help you too.

body-scroll-lock library https://github.com/willmcpo/body-scroll-lock

Video examples of work:

Before using the library (pain): https://truewebstories.ru/sites/default/files/0my_files/blog/2022/scroll-safari-15/before.MP4

After: https://truewebstories.ru/sites/default/files/0my_files/blog/2022/scroll-safari-15/after.MP4

I block everything except the "burger menu" (side menu) from scrolling after that menu is opened. When the menu is closed, all scroll locks are released.

Thanks willmcpo https://github.com/willmcpo and google translate...

PS: Read this issue https://github.com/willmcpo/body-scroll-lock/issues/236 It says that if you install the library through NPM, the problem will not be solved. You need to download it from GitHub - then it will be OK.

Second brilliant solution: Use touch-scrolling in JS (without CSS: overflow: auto and the like).

For example, look at the library: flickity - it has a mode: freescroll.

https://flickity.metafizzy.co/options.html#freescroll

Safari's real trick: it doesn't know we're scrolling.

Related