Skip to content

Web UI: DRY the modals — adopt useModalA11y in 5 hand-rolled modals; route remaining raw fetches through the API client #146

Open

Description

@falbany

Problem

Two consistency gaps across the component layer:

1. Five modals hand-roll the focus trap/Escape instead of the shared hook. LoadConfigModal.tsx:76-98, DirectoryPickerModal.tsx:84-106, LogViewerModal.tsx:133-155, FilePropertiesModal.tsx:92-136, SingleMatchPromptModal.tsx:20-35 each reimplement the Tab trap + Escape + focus restore that utils/useModalA11y.ts already provides (used by ConfirmDialog, TimerModal, SaveAsDialog, ShortcutsModal, BarcodeModal, CameraBarcodeModal, ConfigEditorModal). The drift is real: SingleMatchPromptModal has no Tab trap at all, and the hand-rolled variants lack the hook's "focus drifted out — pull it back" behavior. Two more inconsistencies ride along: ShortcutsModal (:43) and TimerModal (:58) lack the backdrop onClick={onClose} that every other dialog has.

2. Raw fetches bypass the API client and discard error detail.

  • DirectoryPickerModal.tsx:59-74 does a bare fetch("/api/fs/browse?…") with a generic "Failed to browse directory" message, plus local BrowseEntry/BrowseResult interfaces duplicating api/types BrowseResult (which SaveAsDialog imports). client.ts already exposes browseDirectory() (client.ts:320).
  • App.tsx:940-945 (confirmDeleteFile) is the lone raw action call: fetch("/api/actions/delete") with a generic "Failed to delete file" — the server's reason (permission denied vs not found) is swallowed. client.ts has no deleteFile export.

Suggested fix

  • Adopt useModalA11y in all five (SingleMatchPromptModal keeps its Enter/Escape window listener layered on top); add backdrop-click to Shortcuts/Timer for consistency.
  • Call browseDirectory(path) + import the shared type; add deleteFile(filePath) to client.ts following the existing apiError pattern and use it in confirmDeleteFile.

Activity

  1. added
    code-quality
    frontend
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions