AdminLTE 4 handleEscapeKey() bypasses Bootstrap 5 keyboard: false on modals
Environment: AdminLTE 4.x + Bootstrap 5.3.x (standalone) / any browser
Steps to reproduce
- Open a modal with
data-bs-keyboard="false" and data-bs-backdrop="static".
- Press
Escape → modal closes. Expected: stays open.
- Open a second modal stacked on top of the first.
- 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();
}
}
AdminLTE 4
handleEscapeKey()bypasses Bootstrap 5keyboard: falseon modalsEnvironment: AdminLTE 4.x + Bootstrap 5.3.x (standalone) / any browser
Steps to reproduce
data-bs-keyboard="false"anddata-bs-backdrop="static".Escape→ modal closes. Expected: stays open.Escape→ both modals close. Expected: only the topmost closes.Root cause
initFocusManagement()registers adocument-levelkeydownlistener (bubble phase). ItshandleEscapeKey()has two bugs:Bug 1 —
keyboard: falseis ignored