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

In Safari, opening an offcanvas element from the side changes the window width, which can trigger a media query #40908

Open
3 tasks done
MichaelAllenWarner opened this issue Oct 4, 2024 · 1 comment

Comments

@MichaelAllenWarner
Copy link

MichaelAllenWarner commented Oct 4, 2024

Prerequisites

Describe the issue

In Safari, with the macOS scrollbars set to always show, opening an offcanvas element from the side changes the window's width, which can in turn cause a width-based media query to become active or inactive. Since media queries are often used to hide the whole offcanvas-and-button mechanism at certain breakpoints, this is actually a fairly significant bug that can cause menu-functionality to completely break in certain scenarios (i.e., the user's act of opening the offcanvas element can trigger the media query that causes the offcanvas element and its open-button to disappear).

To reproduce, first make sure that you've got the macOS scrollbars set to always show, as in this screenshot (from System Settings in macOS 13.5.2):

Screenshot 2024-10-04 at 10 56 15 AM

Next, open Safari (I'm on v. 16.6) and visit Bootstrap's offcanvas documentation page. Make the window 990px wide (just below the 992px breakpoint), so that what happens will be visually apparent. Then scroll down to the "Toggle right offcanvas" button and click it; you should see the page-layout change while the offcanvas element is open (because the 992px breakpoint kicks in), and you should see it return to its original state once the offcanvas element is closed. Here is a video demonstration:

Screen.Recording.2024-10-04.at.10.55.29.AM.mov

And below is a "worst-case" demonstration from another website, where the triggered breakpoint actually causes the offcanvas element to disappear as a result of it's opening. (At the start of the video, I shrink the window down to just below the breakpoint in question.)

Screen.Recording.2024-10-04.at.11.22.53.AM.mov

The problem is almost certainly related to the right-padding that gets added to the <body> when the offcanvas element is open (it's 15px for me, and the problem arises if I'm within 15px of a media-query breakpoint).

Reduced test cases

https://getbootstrap.com/docs/5.2/components/offcanvas/

What operating system(s) are you seeing the problem on?

macOS

What browser(s) are you seeing the problem on?

Safari

What version of Bootstrap are you using?

v. 5.2.x (latest on the Bootstrap website)

@MichaelAllenWarner
Copy link
Author

Upon further research, I believe that this is directly related to a behavior in Safari where (classic) scrollbars are included in the calculation of width-based media queries. It was filed as a bug in 2011: https://bugs.webkit.org/show_bug.cgi?id=52653

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

1 participant