Skip to content

fix(web): cap the season episode grid at four scrolling rows - #811

Merged
Quick104 merged 1 commit into
mainfrom
fix/season-episode-grid-rows
Aug 28, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/season-episode-grid-rows

Conversation

@Quick104

Copy link
Copy Markdown
Contributor

Problem

Related issue: #804

A full season pushed the cast, crew and everything below it off the page. The grid
rendered every episode, so a 194-episode season (One Piece: Wano Country, the worst
case in my library) was a 9,575px wall of cards before anything else on the page.

The compact hero had the matching problem in the other direction: lg:h-[42vh] is a
fixed height, so a long season summary overflowed above its own clipped backdrop and
took the breadcrumb and title with it.

Approach

The grid shows four rows and scrolls the rest; the compact hero grows downward
instead of overflowing.

Why the cap is measured rather than calculated. These cards pair a fixed-ratio
still with a variable block of text, so there is no row height a stylesheet can name,
and the column count changes at every breakpoint — a calc() would have to encode
both and would drift the moment either changed. useGridRowCap reads the offset of
the first item on the row after the cap. That is correct for any combination of
column count, card content and breakpoint, and it needs no constant kept in sync with
the CSS.

The measurement is written straight to the element rather than held in state: it is a
layout value applied to the node it was read from, so a render round trip would buy
nothing and would make every resize frame cascade.

Two columns is now the narrowest layout, replacing the single-column base. At one
column the capped region measured 2.33 viewports on a 375px screen — a nested
scroll region taller than the screen containing it, which is worse than the problem
being fixed. Two columns brings that to 1.06 while doubling the episodes on screen.

Validation

Measured live against the 194-episode season at every breakpoint. The cap lands flush
with the last visible row in each case (row5.offsetTop − row1.offsetTop − rowGap),
and the section stops scrolling entirely when a season is shorter than the cap:

Viewport Columns Rows Episodes visible Cap vs viewport
1308px 5 4 20 971px 0.76
900px 4 4 16 1160px —
375px 2 4 8 859px 1.06

Also confirmed a short season (8 episodes, 2 rows) gets no max-height and no
scrollport at all, and that a live resize re-measures rather than keeping a stale cap.

  • pnpm run build — passed
  • pnpm exec vitest run — 2613 passed
  • pnpm run lint — 0 errors (165 pre-existing warnings, unchanged baseline)
  • pnpm run format:check — passed

Note

Screenshots to follow — I verified this against a live deployment but cannot attach
images from the CLI. The measurements above are the substantive evidence.

Risks

The episode section is now a nested scroll region, which is a pattern worth being
deliberate about. It stays under ~1.06 viewports at every breakpoint so the whole
region and its scrollbar are visible at once — that bound is why the single-column
layout was dropped. A ResizeObserver re-measures on breakpoint changes; the
regression test covers the case where the grid mounts after a loading skeleton, which
is where an earlier revision of this hook silently froze the cap at first layout.

Provenance

Ports the season-layout half of #805 by @blurbery, rebuilt against the data router now
on main. That branch moved episodes into a horizontal carousel; this keeps the grid,
which is what @Quick104 preferred on review. The navigation and app-wide presentation
changes from that branch are deliberately not included.

AI Disclosure

  • Tool(s): Claude Code
  • Model(s): claude-opus-5[1m]
  • Involvement: Fully AI-generated, human verified — @Quick104 set the direction, chose
    the grid over the carousel, chose the row cap and the two-column mobile base, and
    reviewed the result against a live deployment.
  • Adversarial review: this began as a defect-first review of perf(web): smooth detail layout, resizing, and navigation #805 and the layout was
    then rebuilt from scratch against main. Two bugs were found and fixed during live
    verification rather than by reading the diff: the ResizeObserver bound to a null
    ref while the loading skeleton was showing and never retried (the cap froze at first
    layout and ignored every resize), and tsc -b caught an unchecked index access that
    tsc --noEmit passed. Both are covered by tests.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

🤖 Generated with Claude Code

A full season pushed the cast, crew and everything below it off the page:
the grid rendered every episode, so a 194-episode season was thousands of
pixels of uninterrupted cards. The compact hero had the matching problem
in the other direction — `lg:h-[42vh]` is a fixed height, so a long season
summary overflowed above its own clipped backdrop and took the breadcrumb
and title with it.

The grid now shows four rows and scrolls the rest, and the compact hero
grows downward instead of overflowing.

`useGridRowCap` measures where the row after the cap begins rather than
deriving a height. These cards pair a fixed-ratio still with a variable
block of text, so there is no row height a stylesheet can name, and the
column count changes at every breakpoint — a `calc()` would have to encode
both and would drift the moment either changed. The measurement is written
straight to the element: it is a layout value applied to the node it was
read from, so a render round trip would buy nothing and would make every
resize frame cascade.

Two columns is now the narrowest layout rather than one. At a single
column the capped region measured 2.33 viewports on a 375px screen — a
nested scroll region taller than the screen containing it, which is worse
than the problem being fixed. Two columns brings that to 1.06 while
doubling the episodes on screen.

Closes #804.

Ports the season-layout half of #805 by @blurbery, rebuilt against the
data router now on main. The navigation and app-wide presentation changes
from that branch are deliberately not included here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 56 minutes.

View limit details

Limit details: You’ve used the included review currently available. Your 100 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c3760aa9-1114-4af4-8f82-c68aac0dc87d

📥 Commits

Reviewing files that changed from the base of the PR and between fe7aaf1 and c9807c5.

📒 Files selected for processing (6)
  • web/src/hooks/useGridRowCap.test.tsx
  • web/src/hooks/useGridRowCap.ts
  • web/src/pages/ItemDetail/DetailHero.tsx
  • web/src/pages/ItemDetail/components/SeasonEpisodeGrid.test.tsx
  • web/src/pages/ItemDetail/components/SeasonEpisodeGrid.tsx
  • web/src/pages/ItemDetail/components/SectionSkeletons.tsx

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9807c5f63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// Content can change without the box changing — swapping to a season with a
// different episode count while the grid stays capped at the same height.
useLayoutEffect(applyCap, [applyCap, itemCount]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-measure when grid content changes

Once the grid is capped, its observed border box remains fixed, so ResizeObserver does not fire when child heights change. Because this effect depends only on itemCount, an asynchronous web-font swap or an episode metadata refresh that keeps the same number of episodes can change row offsets without recalculating maxHeight, leaving the fourth row clipped or part of the fifth row visible. Observe the row content/children or include a content revision that changes whenever card layout can change.

Useful? React with 👍 / 👎.

@Quick104
Quick104 merged commit 8d8f9ae into main Aug 28, 2026
7 of 8 checks passed
@Quick104
Quick104 deleted the fix/season-episode-grid-rows branch August 28, 2026 16:06
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