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

[Feat]: Lock scroll when modale is open #667

Open
mrleblanc101 opened this issue Mar 26, 2024 · 9 comments
Open

[Feat]: Lock scroll when modale is open #667

mrleblanc101 opened this issue Mar 26, 2024 · 9 comments
Labels
enhancement New feature or request low priority

Comments

@mrleblanc101
Copy link

Description

Hi,
Would be nice to have an option to lock the page scroll when the modale is open.
This is a pretty standard behavior for modales.

Proposed solution

No response

Additional details

No response

@mrleblanc101 mrleblanc101 added enhancement New feature or request triage yet to be reviewed labels Mar 26, 2024
@osworx
Copy link

osworx commented Mar 27, 2024

Description

Hi, Would be nice to have an option to lock the page scroll when the modale is open. This is a pretty standard behavior for modales.

Has it already, just enable it: https://cookieconsent.orestbida.com/reference/configuration-reference.html#disablepageinteraction

@mrleblanc101
Copy link
Author

No, this would disable page interaction when the modale is not opened too. Also it would add a dark overlay when the cookie bar is present. I'm specifically talking about blocking the scroll when the preference modale is opened

@orestbida
Copy link
Owner

@mrleblanc101 you can achieve this with a simple css rule:

html.show--preferences {
    overflow-y: hidden!important;
}

Although I'm not a fan of this approach as the entire layout is shifted due to the scrollbar being hidden; which is the main reason why there is no scroll lock option.

@orestbida orestbida added low priority and removed triage yet to be reviewed labels Apr 1, 2024
@mrleblanc101
Copy link
Author

Most plugin have an option to handle this case, for exemple body-scroll-lock. It add a padding to compensate when the scroll bar is removed.

There is a also standard CSS way to do this, it's called scrollbar-gutter: stable and is currently being implemented, supported by all browsers except Safari for now.

@alxndr-w
Copy link

What is the benefit from blocking? @mrleblanc101

@mrleblanc101
Copy link
Author

What is the benefit from blocking? @mrleblanc101

@alxndr-w is the standard for a modal

@alxndr-w
Copy link

Ok, but what's the benefit for the user? @mrleblanc101

@mrleblanc101
Copy link
Author

mrleblanc101 commented Aug 13, 2024

@alxndr-w Not accidentally scrolling the page when scrolling the modal, also most browser have scroll chaining which mean when you scroll to the end of the modal, the page behind the modal will scroll. This has been a standard web UX behavior for the past 10-15 years.

@wittjeff
Copy link

Please see also this discussion of how to make background content inert when a modal dialog is up, which helps to ensure screen reader users don't read through the end of a modal and go back to reading page contents without realizing it. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-modal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority
Projects
None yet
Development

No branches or pull requests

5 participants