From 5462e36d10b39efb88d31748a727267d128fbe6c Mon Sep 17 00:00:00 2001 From: Zarl-prog Date: Wed, 3 Jun 2026 04:44:27 +0530 Subject: [PATCH] fix(ui): add missing Escape key handlers for email-lib-modal, model-picker-menu, and sort dropdowns (#1487) CONTEXT: Several interactive elements lacked Escape key handlers: the email library modal was not in dynamicModals, the model-picker popup had no Escape close, and the session/model sort dropdowns only closed on outside click. CHANGE: Adds email-lib-modal to the dynamicModals array in the Escape handler so it gets dismissed via dismissModal. Adds a check for model-picker-menu.open before the modal chain to close the dropdown on Escape. Adds checks for session-sort-dropdown and model-sort-dropdown display=block before the document panel minimize fallback. WHY: Users expect consistent Escape-to-close behavior across all modals, overlays, and popups. These four were the only interactive containers in the app that ignored the Escape key entirely. IMPACT: Pressing Escape now closes the email library modal, model picker popup, session sort dropdown, and model sort dropdown -- matching user expectations and the behavior of every other modal in the app. --- static/app.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/app.js b/static/app.js index d734ae1..32ed5a3 100644 --- a/static/app.js +++ b/static/app.js @@ -532,6 +532,13 @@ function initializeEventListeners() { return; } + // Model picker popup — close before opening any modals + const modelPickerMenu = document.getElementById('model-picker-menu'); + if (modelPickerMenu && modelPickerMenu.classList.contains('open')) { + modelPickerMenu.classList.remove('open'); + return; + } + // Close one modal at a time (last in DOM = topmost) // Map modal id → sidebar list-item id to clear active state const modalItemMap = { @@ -543,7 +550,7 @@ function initializeEventListeners() { }; // Dynamic modals (removed from DOM on close) - const dynamicModals = ['library-modal', 'archive-modal', 'doclib-modal', 'gallery-modal', 'tasks-modal']; + const dynamicModals = ['library-modal', 'archive-modal', 'doclib-modal', 'gallery-modal', 'tasks-modal', 'email-lib-modal']; for (const id of dynamicModals) { const m = document.getElementById(id); if (id === 'gallery-modal') {