Package
filament/filament
Package Version
v5.7.5
Laravel Version
v13.23.0
Livewire Version
v4.3.4
PHP Version
PHP 8.4.23
Problem description
Since upgrading to v5.7.x, opening any modal (action modals, relation manager modals, etc.) on a page that is scrolled or whose modal root sits below the fold, makes the page visibly scroll/jump downward at the moment the modal opens. The modal itself renders correctly, the page behind it scrolls.
This looks like the unfixed other half of #20241. That issue reported the page scroll-jumping on modal close, caused by v5.7.0 removing the .noscroll modifier from the modal's x-trap directive when scroll-locking moved into modal.js. The fix in #20242 addressed only the close path: x-trap got .noreturn, and return-focus moved into JS with an explicit previouslyFocusedElement.focus({ preventScroll: true }) (packages/support/resources/js/components/modal.js, and the same pattern in packages/actions/resources/js/components/modals.js).
The open path still has the same issue. So on open, the browser scrolls the page toward the focused element and the user sees the "slip down".
Before v5.7.0, x-trap.noscroll suppressed this on both open and close. After #20242, close is protected by preventScroll: true but open is not.
Expected behavior
Opening a modal should not change the page's scroll position, matching the pre-5.7.0 behavior (x-trap.noscroll) and the close-side behavior restored by #20242. The open-time initial focus should be applied with preventScroll: true (or the .noscroll modifier restored on x-trap, since documentElement scroll-locking is now handled by modal.js anyway).
Steps to reproduce
1.Open the "Modal scroll repro" page, it has a header action Open modal.
2. Stay scrolled at the top of the page and click "Open modal".
3. The page behind the modal scrolls down
Reproduction repository (issue will be closed if this is not valid)
https://github.com/Apollo139/filament-modal-open-scroll-repro
Relevant log output
Package
filament/filament
Package Version
v5.7.5
Laravel Version
v13.23.0
Livewire Version
v4.3.4
PHP Version
PHP 8.4.23
Problem description
Since upgrading to v5.7.x, opening any modal (action modals, relation manager modals, etc.) on a page that is scrolled or whose modal root sits below the fold, makes the page visibly scroll/jump downward at the moment the modal opens. The modal itself renders correctly, the page behind it scrolls.
This looks like the unfixed other half of #20241. That issue reported the page scroll-jumping on modal close, caused by v5.7.0 removing the
.noscrollmodifier from the modal'sx-trapdirective when scroll-locking moved intomodal.js. The fix in #20242 addressed only the close path:x-trapgot.noreturn, and return-focus moved into JS with an explicitpreviouslyFocusedElement.focus({ preventScroll: true })(packages/support/resources/js/components/modal.js, and the same pattern inpackages/actions/resources/js/components/modals.js).The open path still has the same issue. So on open, the browser scrolls the page toward the focused element and the user sees the "slip down".
Before v5.7.0,
x-trap.noscrollsuppressed this on both open and close. After #20242, close is protected bypreventScroll: truebut open is not.Expected behavior
Opening a modal should not change the page's scroll position, matching the pre-5.7.0 behavior (
x-trap.noscroll) and the close-side behavior restored by #20242. The open-time initial focus should be applied withpreventScroll: true(or the.noscrollmodifier restored onx-trap, since documentElement scroll-locking is now handled bymodal.jsanyway).Steps to reproduce
1.Open the "Modal scroll repro" page, it has a header action Open modal.
2. Stay scrolled at the top of the page and click "Open modal".
3. The page behind the modal scrolls down
Reproduction repository (issue will be closed if this is not valid)
https://github.com/Apollo139/filament-modal-open-scroll-repro
Relevant log output