Skip to content

[Bug] Body scroll lock is removed when opening nested modals #159

@empresarrollo

Description

@empresarrollo

Environment Details

  • PHP Version: 8.2
  • Laravel Version: 12.33.0
  • Vue Version: 3.5.13
  • Inertia.js Version: 2.1.0
  • Inertia Modal Version: 1.0.0-beta.4
  • Reka UI Version: 2.4.1

Bug Report

Description

When opening a nested modal (a modal inside another modal), the body scroll lock is removed, making the background page scrollable. The scroll lock is re-applied only when the nested modal closes.

Steps To Reproduce

  1. Open a modal using <ModalLink> or visitModal()
  2. Inspect the <body> element in DevTools - it should have overflow: hidden, padding-right: 17px, and margin-right: 0px
  3. From inside the first modal, open a second modal (nested modal)
  4. Inspect the <body> element again - all scroll lock styles are removed
  5. Try scrolling the background page - it's now scrollable (should be locked)
  6. Close the nested modal
  7. Body scroll lock is re-applied

Live reproduction: https://github.com/empresarrollo/modal-bug

Grabacion.de.pantalla.2025-10-08.183724.mp4

Expected Behavior

The body element should maintain scroll lock styles (overflow: hidden, padding-right, margin-right) while any modal is open, regardless of nesting depth.

Actual Behavior

Opening a nested modal removes all body scroll lock styles, allowing the background page to scroll. Styles are only re-applied when the nested modal closes and the first modal becomes active again.

Root Cause ?

In vendor/inertiaui/modal/vue/src/Modal.vue (lines 102-119) I thiiiink that the component only renders <DialogOverlay> for the first modal when onTopOfStack and a simple div for the nested modals, and when the DialogOverlay is not present, Reka UI useBodyScrollLock is not used

<Transition v-if="index === 0 && onTopOfStack" ...>
    <DialogOverlay class="im-backdrop ..." />
</Transition>

<div v-if="index > 0 && onTopOfStack" class="im-backdrop ..." />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions