fix: stop the last card in Apple TV rows running off the right edge

Merged
BL
2d ago
+14-5

Problem and reproduction

On Apple TV, moving focus to the last card of a Home row left that card running off the right edge of the screen. Open Home, go down to Continue Watching or any poster row with more cards than fit, and hold right to the end: the last card is cut off. The Studios & Networks and collections rows on the same page end correctly.

Root cause: the media rows use CollectionHStack with .scrollBehavior(.continuousLeadingEdge). That layout re-aligns every scroll to a card's left edge and only lets the row reach its end when the proposed offset is exactly the last window. The cards don't tile into the 1,760 point safe width (four Large landscape cards need 1,848), so the row rested one snap short: 88 points for Large landscape cards and 160 for Large posters. The wider posters from #316 made the poster rows more obvious. The two rows that were fine are plain SwiftUI scroll views with contentMargins.

Implementation and impact

  • Home's media rows (VividCollectionMediaRow) and the rails on a studio or network page now use .scrollBehavior(.continuous), so the focus engine picks the resting offset, the same as the rows that already worked.
  • The Library tab's libraries row and Calendar's trending rails keep their side gutter as a scroll content margin in place of padding inside the content, matching the known-good rows.

Visible change: Home rows no longer snap so the first visible card lines up with the left gutter after each move. They rest where the focus engine leaves them, like the Studios & Networks row.

Alternative considered: keeping the snapping and fixing the end of the row needs a patched fork of CollectionHStack, because the layout class is internal. Not done here.

Apple TV only. Grids and the detail pages' rails were checked in code and already keep their right margin. Focus ownership, restoration and the cards are unchanged.

Validation

  • xcodebuild build for VividTV (Apple TV 4K simulator) succeeds with this change.
  • python3 scripts/ci/check-docs.py passes.

Performance

Not applicable, no performance claim. No benchmark was run.

Testing status

  • Tested? Partly.
  • Environment: Apple TV 4K (3rd generation) simulator, tvOS 27.0.
  • Revision: 29c2f8a1, built together with #318 for the check.
  • Checks and results: On Home's Continue Watching row and a Large poster row, the last card is fully on screen with its focus lift, and a focused card mid-row is fully visible.
  • Limitations: No physical device yet. Not checked: poster rows at the other poster sizes, a studio or network page's rails, the Library tab's libraries row and Calendar's trending rails.

Design impact and approval

  • Design impact: Home rows stop snapping to the left gutter while scrolling, as described above.
  • Approval from blurbery: My own change.

Documentation impact

Updated docs/apple-tv-focus.md (how Home rails scroll, and why the leading-edge snapping is not used).

  • I checked the docs this change affects and updated them in this PR, or explained above why none needed changes.

AI disclosure

I implemented these changes and used Claude Opus as a tool.