Cortex icon indicating copy to clipboard operation
Cortex copied to clipboard

Low: global ? shortcut can open a second dialog over an active confirmation modal

Open dovvnloading opened this issue 3 weeks ago • 0 comments

Impact

Low / keyboard accessibility — the global question-mark shortcut can open the keyboard shortcuts dialog on top of an existing confirmation modal, producing two simultaneous dialogs and competing focus/escape handling. This can interrupt a destructive-action review or an unsaved-changes decision.

Code evidence

  • useHotkey.ts:35–49 checks repeats, composition, modifiers and whether the focused target is an editable field, but does not check if a modal/dialog is already active. A focused confirmation button is not editable.
  • ShortcutsHelpDialog.tsx:14–37 registers useHotkey("?", false, () => setOpen(true)) for the entire app and renders its own Dialog.Root.
  • App.tsx:1036–1059 mounts the shortcut dialog outside the routed view while Settings, Delete chat, or memory confirmation dialogs can be open.
  • ShortcutsHelpDialog.test.tsx tests opening/closing alone, not the two-overlay scenario.

Reproduction

  1. Open the Delete chat confirmation or Settings Save your changes? dialog; leave keyboard focus on one of its buttons.
  2. Press the key that produces ?.
  3. Actual: the global listener opens Keyboard shortcuts without considering the existing modal; both dialogs remain open in React, causing nested modal/focus-trap interaction.
  4. Expected: an active modal retains keyboard focus and exclusive control of shortcuts; the global Help shortcut should not open a second dialog until the first closes.

Fix/tests

Have the shortcut handler refuse opening while any other modal/alertdialog is active (or centralize overlay arbitration and close/suspend the previous overlay). Preserve shortcut operation from ordinary page buttons and noneditable controls. Add a DOM test that opens a confirmation, focuses a button, dispatches ?, and checks no shortcuts dialog appears; verify it opens normally after closing the first dialog.

Reviewed revision: e824fe2dcba0d1be127c9fff165f776186dc37e9. Deterministic keyboard handler path; full browser focus-trap test not run.

dovvnloading avatar Nov 09 '26 13:11 dovvnloading