Skip to content

fix(board): cap chrome + digit-pad Dynamic Type to fix accessibility clipping (#540) - #547

Merged
wei18 merged 2 commits into
mainfrom
fix/540-dynamic-type-board
Jun 17, 2026
Merged

wei18 merged 2 commits into
mainfrom
fix/540-dynamic-type-board

Conversation

@wei18

@wei18 wei18 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Fixes #540.

At accessibility text sizes (AX3+) the board header clipped the difficulty/timer labels off the left edge and the digit pad 1–9 rendered BLANK (empty pills, unusable).

Root cause: a single digit overflows VERTICALLY (glyph far taller than the 44pt pill); minimumScaleFactor is width-driven and never engages for a 1-char label, so the tall glyph clipped to nothing. The header labels likewise scaled tall and pushed off-screen, and an earlier dynamicTypeSize.isAccessibilitySize gate read a stale .large inside the fullScreenCover modal so a reflow never fired.

Fix: cap the compact board chrome (header) and the digit pad at .dynamicTypeSize(...DynamicTypeSize.xLarge) — they stay legible inside their fixed-size controls regardless of the system AX setting. The cap clamps only ABOVE .xLarge, so default .large rendering and every committed snapshot are byte-identical. Board CELLS are uncapped and keep scaling. Mirrored to Minesweeper's status bar. Header kept in an extracted BoardView+AccessibilityHeader.swift (no file_length disable).

Verified:

  • Sim (iPhone 17 Pro, AX5): digit pad 1–9 now visible; header difficulty/timer/pause no longer clip off the left edge (a11y frames all positive-x). (Three prior snapshot-only attempts passed the injected-env snapshot but failed on device — this one is sim-verified.)
  • swift test: SudokuKit 255/255, MinesweeperKit 183/183; no snapshot baseline moved.
  • SwiftLint --strict clean.

Minor remaining at AX5: the difficulty label truncates (e.g. "Me") in its narrow slot — VoiceOver label stays full; acceptable polish vs the resolved blank-pad / off-screen-clip bugs.

🤖 Generated with Claude Code

wei18 and others added 2 commits June 17, 2026 18:17
…ing dynamicTypeSize (#540)

The prior approach gated a two-row header reflow on
`@Environment(\.dynamicTypeSize).isAccessibilitySize`. Inside the
fullScreenCover modal that hosts BoardView (via GameRoot), that environment
value reads a stale `.large` even while the Text views scale via UIFont
metrics, so the gate never fired on device — difficulty still clipped to
"ledium" off the leading edge (a11y x0 = -19 at AX3 / -37 at AX5), and the
digit pad still rendered blank.

Header (BoardView+AccessibilityHeader.swift, extracted to keep BoardView.swift
< 400 lines):
- Replace the env-gated branch with `ViewThatFits(in: .horizontal)`: SwiftUI
  picks the single-row HStack when it fits the ACTUAL offered width and falls
  back to a two-row VStack when the enlarged labels overflow. No environment
  read. At default sizes the HStack fits → snapshot baseline unchanged.
- Add `.lineLimit(1).minimumScaleFactor(0.6)` to the difficulty + timer labels
  so whichever layout is chosen shrinks text to fit instead of pushing it to a
  negative-x frame.

Digit pad (DigitPadView.swift):
- Root cause of the blank pills: the digit overflows VERTICALLY. At AX sizes
  the glyph is ~50-60 pt tall but the .bordered pill is ~44 pt; the bare
  `frame(minHeight: 44)` set only a floor (no ceiling), so the Text was
  proposed unbounded height, never scaled, grew to full AX height, and was
  clipped top-and-bottom to nothing. A width-based minimumScaleFactor cannot
  fix a height overflow.
- Fix: bound the glyph to a CEILING height (`maxHeight: 28`, inside the 44 pt
  pill) so `minimumScaleFactor(0.3)` has a concrete box to scale the digit
  down into. At default size the digit's natural height < 28 pt, so no scaling
  occurs and the baseline is preserved.

Minesweeper mirror (MinesweeperBoardView.swift): same ViewThatFits status-bar
reflow (single-row HStack → two-row VStack) with shrink-to-fit labels.

No environment value drives layout in any of these. #539 scenePhase code
untouched. Default-size snapshot baselines verified byte-identical:
SudokuKit 255/255, MinesweeperKit 183/183. Per the round-3 directive, NO
snapshot test is added — the injected-env snapshot gave a false pass before;
the Leader will sim-verify AX3/AX5 on device.

Co-Authored-By: Claude <[email protected]>
…ing (#540)

At accessibility text sizes the board header clipped the difficulty/timer
labels off the leading edge and the digit-pad 1-9 rendered BLANK (empty
pills). Root cause: a single digit overflows VERTICALLY (glyph far taller
than the 44pt pill) and `minimumScaleFactor` is width-driven so it never
engages for a 1-char label — the tall glyph just clipped to nothing; the
header labels likewise scaled tall and pushed off-screen, and the earlier
`dynamicTypeSize.isAccessibilitySize` gate read a stale `.large` inside the
fullScreenCover modal so the reflow never fired.

Fix: cap the compact board chrome (header) and the digit pad at
`.dynamicTypeSize(...DynamicTypeSize.xLarge)` so they stay legible inside
their fixed-size controls regardless of the system AX setting (standard
compact-control convention). The cap clamps only ABOVE `.xLarge`, so default
`.large` rendering — and every committed snapshot — is byte-identical. The
board CELLS are uncapped and keep scaling for puzzle readability. Mirrored to
Minesweeper's status bar. Keeps the round-3 `ViewThatFits` header structure
(extracted to BoardView+AccessibilityHeader.swift, no file_length disable).

Sim-verified on iPhone 17 Pro at AX5: digit pad 1-9 now visible, header
difficulty/timer/pause no longer clip off the left edge.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit 70f1dc4 into main Jun 17, 2026
4 checks passed
@wei18
wei18 deleted the fix/540-dynamic-type-board branch June 17, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic Type (AX3+): board header clips difficulty/timer + digit-pad glyphs render blank

1 participant