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

Đang mở
#146 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, react, typescript
Lĩnh vực
api, frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
1
Fork
1
Merge trung bình
4 giờ 46 phút
Pull request đã merge (30 ngày)
55

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của falbany/ProFiles

Tất cả issue của falbany/ProFiles

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.