Skip to content

Fix hero rail hit-testing: constrain tap area to laid-out frame - #94

Merged
imbenjamin merged 1 commit into
developfrom
hotfix/hero-rail-tap-hitbox
Aug 18, 2026
Merged

Fix hero rail hit-testing: constrain tap area to laid-out frame#94
imbenjamin merged 1 commit into
developfrom
hotfix/hero-rail-tap-hitbox

Conversation

@imbenjamin

Copy link
Copy Markdown
Owner

Bug

The Home screen hero item was very hard to tap: taps on the center mostly did nothing, and taps on the right side of the currently-visible item registered as a tap on the next item instead.

Root cause

BackdropLogoOverlay's backdrop image is .resizable().aspectRatio(contentMode: .fill), which lays out larger than its container whenever the source image's aspect ratio doesn't match the frame — .clipped() only crops what's rendered, not the view's actual layout geometry. With no explicit tap shape, HeroRailCard's NavigationLink inferred its hit-test region from that oversized, unclipped geometry instead of the visually clipped frame.

Confirmed live via an accessibility-tree dump on the hero rail: every loaded page's reported frame was ~758pt wide against a 402pt screen/page width (one page still on its loading placeholder measured correctly at 402pt in the same dump, isolating the backdrop image as the cause). The overlapping regions between adjacent pages resolved to whichever page was later in hit-test order — the next page — matching the reported asymmetry.

Fix

Adds .contentShape(Rectangle()) to BackdropLogoOverlay itself, so any caller wrapping it in a tappable control gets a correctly-bounded tap area — not just the hero rail.

Verification

  • Rebuilt + reinstalled in Simulator, re-measured the accessibility tree: every hero page now reports exactly width: 402, matching the true page width, no overlap.
  • Live tap test: tapped near the far-right edge of the currently-displayed hero item and it correctly opened that item's own detail page.
  • BackdropLogoOverlayTests (7 tests, tilt-rotation math, unaffected by this change) still pass.

🤖 Generated with Claude Code

BackdropLogoOverlay's backdrop image is `.resizable()
.aspectRatio(contentMode: .fill)`, which lays out larger than its
container whenever the source image's aspect ratio doesn't match —
`.clipped()` only crops what's rendered, not the view's actual layout
geometry. With no explicit tap shape, HeroRailCard's NavigationLink
inferred its hit-test region from that oversized, unclipped geometry
instead of the visually clipped frame.

Confirmed live via an accessibility-tree dump on the hero rail: every
loaded page's reported frame was ~758pt wide against a 402pt
screen/page width (one page still on its loading placeholder measured
correctly at 402pt in the same dump, isolating the backdrop image).
The overlapping regions between adjacent pages resolved to whichever
page was later in hit-test order — the *next* page — matching the
reported "right side taps the next item" bug.

Adds `.contentShape(Rectangle())` to BackdropLogoOverlay itself so any
caller wrapping it in a tappable control gets a correctly-bounded tap
area, not just the hero rail. Re-verified post-fix: every hero page
now reports exactly `width: 402` with no overlap, and a live tap near
the right edge of the current item opens that item's own detail page.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@imbenjamin
imbenjamin merged commit d09a734 into develop Aug 18, 2026
2 checks passed
@imbenjamin
imbenjamin deleted the hotfix/hero-rail-tap-hitbox branch August 18, 2026 10:34
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.

1 participant