Do not remove scrollbars by default when modal opens
Closed this issue · 1 comments
Right now, when the modal opens it modifies the style of the body element to remove the scrollbars by setting overflow: hidden;
. This might not always be desirable and there is no option for the modal to disable this behaviour.
As a side note, the native <dialog>
element does not remove scrollbars by default but leaves it to the user to decide.
Therefore, the modal should not assume and remove scrollbars by default but the user can do it if this is the desired behaviour. Nowadays, this is very easy using the :has()
pseudo-class. For example:
html:has(modal-element[open]) {
overflow: hidden;
}
In another note, the modal's body should prevent scroll chaining when the document's scrollbars are visible and the modal's content overflows, using overscroll-behavior: contain;
.