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

Made the page unscrollable while the modal is visible #17247

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

oleq
Copy link
Member

@oleq oleq commented Oct 9, 2024

Suggested merge commit message (convention)

Fix (ui): Made the page unscrollable while the modal is visible. Closes #17093.


Possible strategies

There are two main strategies for freezing the web page scroll available:

  1. overflow: hidden on <body>: A very straightforward recipe. It fails in iOS, though. Still, I chose this one because I figured out we can sacrifice the mobile UX for the sake of a simple code and a quicker solution. Besides, Bootstrap.js uses this one and they don't seem to mind at all.
  2. position: fixed on <body>: Initially, I went with this one because it looked promising but soon I realized it has some drawbacks (also in non-mobile browsers). For instance, it causes page reflows when the body is narrower than the viewport or when the body was positioned with absolute in the first place. It requires some extra code (the article shows just basics, there's more to it once you look into it) and feels more complex. I decided it was not worth the hassle (for now).
  3. A hybrid that uses overflow: hidden in most cases and position: fixed for iOS with additional hacks. It's a fairly popular MIT-licensed npm module but I found it overkill for what we need right now.

Scope

Currently, only media embed, insert image by URL, and revision history save modals benefit from the change.

Misc

There's a manual test brought in this PR that helps test the behaviors.

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

Successfully merging this pull request may close these issues.

Disable page scroll when modal is open
1 participant