فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

fix(ux): plain Enter must not silently save a financial dialog while Cancel or form fields are focused

davoodmehraban89 committed Oct 30, 2026 at 23:37 UTC 8dbebd1e40ec7f1309b281c7b42c3689a8677208
1 file changed +11 -7
src/core/KeyboardShortcuts.js
+11 -7
@@ -105,14 +105,18 @@ class KeyboardShortcutsImpl {
105 return;
106 }
107
108 - // ────── Enter → تأیید (فقط داخل مودال، نه در textarea) ──────
109 - if (e.key === 'Enter' && !e.shiftKey && this.settings.enterConfirms) {
108 + // ────── Plain Enter: preserve keyboard semantics of focused controls ──────
109 + // The previous global handler could SAVE a financial form when focus was
110 + // on "Cancel" or a select/autocomplete field. Let native Enter activate
111 + // buttons, links, dropdowns and inputs. Ctrl+Enter remains the deliberate
112 + // confirm shortcut; plain Enter only confirms when the dialog surface
113 + // itself (not a form control or editable child) has focus.
114 + if (e.key === 'Enter' && !e.shiftKey && this.settings.enterConfirms && modal) {
115 const active = document.activeElement;
111 - if (active && active.tagName === 'TEXTAREA') return;
112 - if (modal) {
113 - e.preventDefault();
114 - this._clickPrimaryButton(modal);
115 - }
116 + if (!active || !modal.contains(active)) return;
117 + if (active !== modal.querySelector('.modal-card')) return;
118 + e.preventDefault();
119 + this._clickPrimaryButton(modal);
120 return;
121 }
122