Timeline: preserve intrinsic width in shrink-to-fit containers - #8369
Timeline: preserve intrinsic width in shrink-to-fit containers#8369liuliu-dev wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 26383db The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
It introduces avoidable re-renders in Timeline’s resize observer handler and contains potentially flaky strict y-position assertions in the new Playwright test.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 2
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
e2e/components/Timeline.test.ts — This assertion uses a strict y comparison; depending on subpixel rounding, the Actions container… |
|
packages/react/src/Timeline/Timeline.tsx — useResizeObserver will call setIsNarrow on every resize (and potentially on mount), even when the… |
What changed in this PR
This PR fixes a regression where Timeline could collapse to 0px width in shrink-to-fit containers by removing inline-size containment, while preserving the <480px “Actions wrap below Body” responsive behavior via a measured-width (ResizeObserver) toggle.
Changes:
- Replaced the CSS container-query approach with a
data-timeline-narrowattribute driven byuseResizeObserverinTimeline. - Updated Timeline CSS (and related feature-story CSS) to key narrow-layout rules off
data-timeline-narrowinstead of@container. - Added unit ref-forwarding coverage and new Playwright coverage for intrinsic-width retention and the 479px/480px Actions wrap boundary.
| File | Description |
|---|---|
| packages/react/src/Timeline/Timeline.tsx | Adds ResizeObserver-driven data-timeline-narrow attribute and merges forwarded + internal refs. |
| packages/react/src/Timeline/Timeline.module.css | Removes container-type and switches narrow Actions layout rules to attribute-based selectors. |
| packages/react/src/Timeline/Timeline.features.stories.module.css | Updates feature-story narrow styling to use data-timeline-narrow instead of container queries. |
| packages/react/src/Timeline/__tests__/Timeline.test.tsx | Adds unit tests to verify ref forwarding for both div and ol roots. |
| e2e/components/Timeline.test.ts | Adds Playwright regression tests for intrinsic width in shrink-to-fit and 479/480 Actions wrapping. |
| .changeset/timeline-intrinsic-width.md | Adds patch changeset describing the regression fix and preserved responsive behavior. |
Suppressed comments (1)
e2e/components/Timeline.test.ts:84
- This assertion uses a strict y comparison; when Actions are inline with Body, their y positions can be equal (same row) due to layout/rounding. Use a non-strict comparison to reduce flakiness while still verifying Actions aren’t wrapped below Body at >=480px.
element.style.width = '480px'
})
await expect(timeline).not.toHaveAttribute('data-timeline-narrow')
await expect.poll(async () => (await actions.boundingBox())?.y).toBeLessThan((await body.boundingBox())?.y ?? 0)
})
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Integration test results from github/github-ui PR:
All checks passed! |
joshblack
left a comment
There was a problem hiding this comment.
@liuliu-dev is there any way to avoid using a resize observer for this? Just to avoid the layout shift during hydration (hope that makes sense, let me know if not!)
That makes sense. A viewport media query would avoid the hydration shift, but wouldn’t work correctly in split views. I couldn’t find a css only option that preserves both behaviors. |

Fixes a regression introduced in #8169.
Removing inline-size containment allows content-sized Timelines to contribute to their containing block's intrinsic width instead of collapsing to
0px.The responsive Actions layout is preserved by observing the Timeline's rendered width and applying the narrow grid layout below
480px.Changelog
New
Changed
480px.Removed
Rollout strategy
Testing & Reviewing
479pxand remain inline at480px.divand feature-flaggedolroots.With Actionsto the Timeline VRT matrix.