Skip to content

fix(sudoku): digit pad design-audit findings — armed badge contrast collapse, VoiceOver l10n bypass, doc drift (8 findings) #855

Closed

Description

@wei18

Eight findings from a systematic design audit of DigitPadView.swift (design-audit skill run, 2026-07-17; static analysis + token-computed contrast ratios — F-5 flagged PLAUSIBLE, unverified on device). Severity: 5 MAJOR / 3 MINOR. Full pre-flight checklist adjudication included below.


Explorer 已回報,所有支撐事實到位。以下為稽核報告(純靜態分析 + 依 design-system.md 色票實算對比度;未動任何檔案)。


DigitPadView.swift UI/UX 稽核報告

對象:Packages/SudokuKit/Sources/SudokuUI/Board/DigitPadView.swift(352 行)— 數字鍵盤,含 compact(iPhone)與 regular(Mac)兩種佈局。畫面類型:按鈕群/切換控制。
加載判準:pre-flight checklist 全 6 條 + hig-liquid-glass.md(規範性)+ ux-writing.md + 專案 docs/designs/design-system.md。

Pre-flight checklist 逐條

# 條目 判定 證據
1 動畫必接 reduce-motion N-A 本檔無任何自訂動畫;armed/pencil 狀態切換為即時 restyle,無位移/縮放
2 色彩 token 語意不挪用 PASS(附註) surface.primary 被拿來當 on-accent 文字 ink(DigitPadView.swift:170,274,320)— 語意倒置,但屬 #786/#797 有記錄的裁定且對比實測過;缺點是 design-system.md 無 text.onAccent token,裁定只活在 code 註解裡(見 F-7)
3 觸控熱區 ≥44pt PASS 控制列 4 鍵 minWidth:44, minHeight:44(:80,89,100,111);compact 數字鍵 minHeight:56(:216);Mac 鍵 ≥64pt(:337)。均達 HIG default + WCAG AAA
4 互動語意改變時 a11y 同步改 部分 FAIL 武裝狀態改變有 announcement(BoardView.swift:135,#790,已本地化)✓;但數字鍵無 accessibilityHint 說明「有選取=落子/無選取=武裝」的語意分歧(整個 SudokuUI 僅 DailyStripView 有一處 hint),VoiceOver 使用者按下前無從得知這次點擊會做哪件事(見 F-5)
5 設計語言檔與實作同步 FAIL docs/designs/05-board.md 三處仍是 #658(2026-07-01)前的舊規格:§b wireframe 畫 1×9 strip + 三鍵控制列(L38-40)、§c preview skeleton 仍 1×9 minWidth:36(L173-183)、§d spec table 寫 ≥36pt width(L280)。本檔自己的 header 註解 :7 也還寫「1×9 digit strip」,與 :120 的 3×3 實作自相矛盾(見 F-4)
6 對比度實測不肉眼估 部分 FAIL prominent 路徑有實測記錄(4.83:1 / 7.42:1,:164-165)✓;但 armed 鍵內部的 remaining 徽章沒有跟著換 ink,實算對比崩潰(見 F-1);0.35 淡化的「可用」鍵約 1.5:1(見 F-2);light mode remaining==1 的 sage caption 估約 4.0:1 < 4.5(見 F-6)

Findings(依嚴重度)

F-1|MAJOR|armed 鍵內的 remaining 徽章對比崩潰,dark mode 近乎隱形(DigitPadView.swift:169-170 + :208-213,未實機驗證,數值由 token 實算)
#797 把 on-accent ink(surface.primary)加在 compactDigitLabel 整體上,但徽章 Text("\(remaining)") 保有自己的顯式 foregroundStyle,註解還特別說它「unaffected」——這正是問題:武裝時鍵面是 accent 實心填色,徽章卻仍用 text.secondary 或 accent 色。實算:light #54595F on #5C7A4F ≈ 1.45:1;dark #A8ADB3 on #9BB87E ≈ 1.02:1(不可辨);remaining==1 時 accent-on-accent ≈ 1.0:1(兩種模式都隱形)。違反 WCAG 1.4.3(caption2 需 4.5:1)。建議修法:armed 分支下徽章也切到 on-accent ink(或武裝時隱藏徽章並靠 accessibilityValue 承載)。

F-2|MAJOR|「已用完但可武裝」的鍵:enabled 卻淡化到 0.35,對比與 affordance 雙重失效(:182-183、:195-197)
無選取時 remaining==0 的鍵是 enabled(可武裝供筆記用),卻仍套 0.35 opacity——複合後數字對 key 面對比估約 1.5:1。WCAG 1.4.3/1.4.11 的停用豁免只適用真正 disabled 的元件;這顆是可互動的,不豁免。且「看起來停用、實際可點」是 affordance 誤導。#790 只修了 armed 案例,unarmed-enabled 案例仍在。建議:enabled 態改用「徽章消失/打勾」等非整鍵淡化的 exhausted 信號,或至少把淡化幅度收到對比仍過 3:1 的程度。

F-3|MAJOR|三條 accessibilityValue 字串繞過 L10n,VoiceOver 只念英文(:102、:185)
Off、%lld remaining、fully placed 不在 App/Sudoku/Resources/Localizable.xcstrings(explorer 逐 key 查證;On/Digit %lld 是靠別處字面量意外入庫)。三元運算式讓字串以 String 而非 LocalizedStringKey 推斷,萃取器不收。違反專案「user-visible 字串 7 locales」的 binding 規則——VoiceOver 輸出是 user-visible。與 Jul 4 既有 observation 一致,至今未修。建議:改走 Text(...) 或顯式 String(localized:) 並補 7 locales。

F-4|MAJOR|設計文件與實作漂移 16 天(checklist #5,證據見上表)
05-board.md 的 iPhone 規格(1×9、三鍵、≥36pt)自 #658 起全數過時;本檔 header :7 同病。依 checklist #5 應「同 PR 二選一對齊」,這筆已欠了兩週多。修法是文件側更新(3×3 / 56pt / 四鍵 44pt),非程式側。

F-5|MAJOR(PLAUSIBLE,未實機驗證)|disabled 的 Undo/Redo 可能不會灰化(:76-81、:84-90)
Undo/Redo 的 Image 上掛了無條件的顯式 .foregroundStyle(theme.accent.primary.resolved);plain/automatic button style 的 disabled 灰化是靠環境 ink,顯式 style 會蓋掉它——與本 repo 已記錄的 .foregroundStyle footgun(#797/#786 系列,以及「conditional scoping required for disabled-state baseline preservation」的既有教訓)同型。若成立,canUndo == false 時按鈕滿彩、看似可點。開局畫面(canUndo=false)一張 sim 截圖即可證偽/證實。對照組:同列的 Notes/Erase 永不 disabled,所以只有 Undo/Redo 受影響。

F-6|MINOR|light mode remaining==1 的 sage caption 估約 4.0:1(:211-213)
#5C7A4F 在純白上是 4.84:1(過),但 .bordered 的 tint 填色(估 ~15% accent over white)把有效對比壓到約 4.0:1,低於 caption2(11pt 小字)所需 4.5:1。依 checklist #6「數值不得四捨五入」,需 Accessibility Inspector 實測定案(系統填色不透明度是我的假設)。dark mode 估 5.5:1,過。「last one」提示本身有數字承載資訊、顏色僅是強調,不構成 color-only 違規。

F-7|MINOR|on-accent ink 模式無 token、無設計文件記載
surface.primary 當文字 ink 的裁定散在三處 code 註解(:170,274,320),design-system.md 的 token 表沒有 text.onAccent。F-1 正是這種「模式靠註解傳播」的直接後果——下一個 prominent 表面很容易再漏。建議 design-system.md 增列 token 並集中裁定記錄。

F-8|MINOR|數字鍵無 accessibilityHint 說明雙語意(checklist #4 的另一半;:184-186)
建議依 hasSelection 動態給 hint(如 "Places the digit in the selected cell" / "Arms the digit for placement")並本地化——announcement 只覆蓋事後,hint 覆蓋事前。

待裁定(不計嚴重度,交使用者)

  • Mac 資訊落差:Mac 版無 remaining 徽章、無用完限制(:306-307 註明刻意)。mirror principle 是跨 app 不是跨平台,但同一個玩家換裝置會少掉一組資訊,值得一句裁定。
  • exhausted 數字的筆記路徑不一致:選取格 + 筆記模式下,用完的數字被 .disabled 擋掉(:182 的 gate 不看 pencilMode);但走 digit-first 武裝路徑卻允許對用完的數字做筆記。同一個意圖,兩條路徑一通一堵。
  • HIG 元件間距:控制列 spacing 0、數字格 8pt,低於 HIG 建議的 bezel 元件 ~12pt padding;因實際熱區極大(控制鍵約 1/4 列寬、數字鍵 ~100×56pt),誤觸風險低,已有 spacing-exempt 記錄,可維持。

做得好的部分(稽核平衡):觸控目標全面 ≥44pt 且留有註解出處;armed announcement 有做且本地化(#790);digitButtonOpacity 抽成可單測的 pure func(有 DigitPadViewOpacityTests);ux-writing 全部 1 字動詞、語意精確;Erase 放右緣對齊右手拇指熱區;VoiceOver 走訪順序(控制列→1..9 逐列)邏輯正確。

我沒驗的部分與信心度

  • 全部 findings 均為靜態分析,未跑模擬器、未開 Accessibility Inspector。F-1/F-2/F-6 的對比值是由 design-system.md 色票實算,其中 .bordered 填色不透明度(~15%)是假設值——F-1 的 armed 填色是實心 accent、不含假設,信心高;F-6 依賴假設,信心中。
  • F-5 未證實,是與已知 footgun 同型的推論;一張開局截圖可定案。
  • VoiceOver 實際朗讀行為(trait 變化是否播報、value 語序)、Dynamic Type AX3/AX5 下控制列與 Mac 佈局的實際表現(兩者無 cap)皆未實跑——依 memory 教訓,Dynamic Type 類結論必須 sim 驗證後才可定嚴重度。

回寫建議(知識庫)

F-1 是一個可沉澱的新模式:「on-accent ink 修復必須涵蓋 label 內所有保有自己 foregroundStyle 的子節點,否則子節點在 accent 實心填色上直接隱形」——建議記入 design-app 的 case notes / capture-backlog。本次為純稽核,我沒有動 design-app repo;要我補寫再說一聲。

🤖 Generated with Claude Code

Activity

  1. wei18 commented on Jul 17, 2026

    @wei18
    OwnerAuthor

    🔒 Claiming — session 064a54f6 (Leader). Triage: F-1/F-2/F-3/F-6/F-8 are code fixes in DigitPadView (+L10n for F-3/F-8); F-4 is doc-side (05-board.md + header comment); F-7 adds the text.onAccent token entry to design-system.md. F-5 is PLAUSIBLE-only — implementer must FIRST sim-verify with a fresh-board screenshot (canUndo=false) and fix only if confirmed; if disproven, record why. The three 待裁定 items (Mac remaining-badge info gap / exhausted-digit notes-path inconsistency / spacing exemption) are surfaced to the owner separately — NOT in this fix's scope. Dispatching implementation with the above scope.

  2. wei18 commented on Jul 17, 2026

    @wei18
    OwnerAuthor

    Owner delegated the 待裁定 items to Leader judgment (2026-07-17); adjudications: (1) Mac remaining-badge gap — keep as-is, document: the omission is deliberate and commented (:306-307); the fix is recording the adjudication in docs/designs (rides F-7's design-system.md edit), not adding badges to Mac. (2) Exhausted-digit notes-path inconsistency — unify to ALLOW: the selected-cell path's disabled gate (:182) should check pencilMode and permit pencil placement on exhausted digits, matching the digit-first path (notes are annotations; remaining-count is irrelevant to them). Add a test pinning both paths agree. (3) Control-row spacing: existing spacing-exempt record stands, no change. These join the dispatch scope.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions