Skip to content

[WC-3595]fix(accordion-web): animate groups with grid rows instead of measured height - #2534

Open
gjulivan wants to merge 1 commit into
mainfrom
fix/accordion-grid-row-animation
Open

gjulivan wants to merge 1 commit into
mainfrom
fix/accordion-grid-row-animation

Conversation

@gjulivan

Copy link
Copy Markdown
Collaborator

Pull request type


Description

Accordion group content was animated by measuring it with getBoundingClientRect and writing an inline height, kept up to date by a debounced ResizeObserver. That caused several problems:

  • The height lagged behind content changes, so content (for example validation messages) was cut off for a few frames.
  • Groups set to "load content when expanded" opened empty and then jumped.
  • A group toggled while hidden (for example in an inactive tab) never received transitionend and stayed stuck at 0px.

The group is now a CSS grid whose content row transitions between 0fr and 1fr, so the browser sizes the content at all times. The content wrapper clips during the animation and is visibility: hidden when collapsed. The DOM structure and class names are unchanged, so Atlas and custom theme selectors still match.

  • transitionend only completes the toggle for the group's own grid-template-rows transition (not bubbled child transitions)
  • A fallback timer completes the toggle when transitionend does not fire; with no transition (reduced motion, theme override) it completes immediately
  • "Load when expanded" content renders at the start of the expand
  • prefers-reduced-motion disables the transition
  • The ResizeObserver hook is removed

pnpm test passes (73 tests); pnpm lint has no errors.

What should be covered while testing?

  • Expand and collapse groups with animation on: smooth, no clipping or jump at the end
  • Content that changes height while expanded (validation messages, conditional visibility) is never cut off
  • Groups with "Load content: when expanded" show content during the expand animation
  • Accordion inside an inactive tab container: toggle via a button, then switch tabs; the group is in the correct state
  • With OS "reduce motion" on, groups toggle instantly
  • Collapsed content is not focusable with the keyboard
  • Atlas styling and custom theme overrides still apply

🤖 Generated with Claude Code

… height

Group content was animated by measuring it with getBoundingClientRect and
writing an inline height, kept up to date by a debounced ResizeObserver.
The height lagged behind content changes, so content was cut off for a few
frames, and groups that load content when expanded opened empty and jumped.
A group toggled while hidden (e.g. in an inactive tab) never got
transitionend and stayed stuck at 0px.

The group is now a grid whose content row transitions between 0fr and 1fr,
so the browser sizes the content at all times. The content wrapper clips
during the animation and is visibility: hidden when collapsed. The DOM and
class names are unchanged, so Atlas and custom theme selectors still match.

- transitionend only completes on the group's own grid-template-rows
- a fallback timer completes the toggle when transitionend does not fire;
  with no transition (reduced motion, theme override) it completes at once
- "load when expanded" content renders at the start of the expand
- prefers-reduced-motion disables the transition
- remove the ResizeObserver hook

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gjulivan
gjulivan requested a review from a team as a code owner November 16, 2026 22:36
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

✅ Approved — no issues found


What was reviewed

File Change
accordion-web/src/components/AccordionGroup.tsx Replaced measured-height animation and ResizeObserver with a transitionend handler plus a fallback timer. Content now renders when expanding starts.
accordion-web/src/ui/accordion-main.scss Group is now a CSS grid. The content row animates between 0fr and 1fr, collapsed content uses visibility: hidden, and reduced motion disables the transition.
accordion-web/src/utils/resizeObserver.ts Removed.
accordion-web/src/components/__tests__/*.spec.tsx Removed the ResizeObserver mocks. Added animated-path tests for transitionend, the fallback timer, no transition, and load-when-expanded.
accordion-web/CHANGELOG.md Added a user-facing "Fixed" entry under Unreleased.

Skipped (out of scope): dist/, pnpm-lock.yaml

CI: pending: code quality check, E2E matrix, sigridci, Snyk code · unrelated failures: security/snyk (external scanner; I did not inspect the log)


Positives

  • The transitionend handler checks both target === currentTarget and propertyName. Transitions bubbling up from nested accordions or the header icon can't complete the toggle early.
  • The fallback timer is cleared on unmount and on completion. It also covers hidden-tab groups and the no-transition case (reduced motion or a theme override).
  • The changelog entry describes behavior only, and the tests cover each new branch.

@gjulivan gjulivan changed the title fix(accordion-web): animate groups with grid rows instead of measured height [WC-3595]fix(accordion-web): animate groups with grid rows instead of measured height Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant