فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix(ux): stop double-Escape closing nested financial dialogs and select only topmost modal for shortcuts
davoodmehraban89 committed
Oct 30, 2026 at 23:35 UTC
bb0b6c133f2efc4d5b98076c80a76d2ace629d27
1 file changed
+7
-2
src/core/KeyboardShortcuts.js
+7
-2
@@ -68,8 +68,10 @@ class KeyboardShortcutsImpl {
68
_onKeyDown(e) {
69
if (!this.settings.enabled) return;
70
71
- const modal = document.querySelector('.modal-backdrop.active') ||
72
- document.querySelector('.modal-backdrop');
71
+ // Always target the topmost dialog. The old query selected the first
72
+ // backdrop, so Enter/Ctrl+S could affect a hidden parent dialog.
73
+ const backdrops = document.querySelectorAll('.modal-backdrop');
74
+ const modal = backdrops[backdrops.length - 1] || null;
75
76
// ────── Ctrl+S / Cmd+S ──────
77
if (this._isCtrlS(e)) {
@@ -94,6 +96,9 @@ class KeyboardShortcutsImpl {
96
// ────── Escape → بستن مودال ──────
97
if (e.key === 'Escape' && this.settings.escapeCloses) {
98
if (modal) {
99
+ // ModalManager owns stacked dialogs and already closes exactly one
100
+ // top dialog on Escape; a second click here closed both dialogs.
101
+ if (window.FINORA?.Modal?.stack?.length) return;
102
e.preventDefault();
103
this._clickCloseButton(modal);
104
}