Skip to content

AdminLTE 4 handleEscapeKey() bypasses Bootstrap 5 keyboard: false on modals #5993

@braytac

Description

@braytac

AdminLTE 4 handleEscapeKey() bypasses Bootstrap 5 keyboard: false on modals

Environment: AdminLTE 4.x + Bootstrap 5.3.x (standalone) / any browser

Steps to reproduce

  1. Open a modal with data-bs-keyboard="false" and data-bs-backdrop="static".
  2. Press Escape → modal closes. Expected: stays open.
  3. Open a second modal stacked on top of the first.
  4. Press Escape → both modals close. Expected: only the topmost closes.

Root cause

initFocusManagement() registers a document-level keydown listener (bubble phase). Its handleEscapeKey() has two bugs:

Bug 1 — keyboard: false is ignored

handleEscapeKey(event) {
    const activeModal = document.querySelector('.modal.show');
    if (activeModal) {
        activeModal.querySelector('[data-bs-dismiss="modal"]')?.click(); // synthetic click
        event.preventDefault();
    }
}

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