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

未关闭
#146 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, react, typescript
领域
api, frontend

调研方向

Read utils/useModalA11y.ts, then compare its use in ConfirmDialog and the five named modal files: LoadConfigModal.tsx, DirectoryPickerModal.tsx, LogViewerModal.tsx, FilePropertiesModal.tsx, and SingleMatchPromptModal.tsx. Also inspect client.ts around browseDirectory() and apiError, plus App.tsx around confirmDeleteFile. Done means the five modals use the shared hook, ShortcutsModal and TimerModal close on backdrop clicks, and both directory browsing and file deletion use the API client while preserving useful error details.

由索引模型根据 Issue 内容生成。

描述

code-quality frontend

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.
主要语言
Python
星标
1
派生
1
平均合并
4 小时 46 分钟
30 天内合并 PR
55

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

falbany/ProFiles 的其他 Issue

查看 falbany/ProFiles 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。