Skip to content

fix(list): don't re-render List.Accordion when its expand animation ends - #5359

Open
akysil wants to merge 1 commit into
callstack:mainfrom
akysil:fix/5341-list-accordion-expanding-it-in-a-test-lo
Open

akysil wants to merge 1 commit into
callstack:mainfrom
akysil:fix/5341-list-accordion-expanding-it-in-a-test-lo

Conversation

@akysil

@akysil akysil commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Motivation

When an expanding List.Accordion finished its animation in a Jest test, React logged "An update to List.Accordion inside a test was not wrapped in act(...)", failing setups that fail on console.error. Finishing an expand no longer updates the accordion's state, so expanding logs nothing.

Related issue

Fixes #5341

Screenshots / Videos

n/a: the accordion looks the same.

Test plan

In the example app, open List.Accordion:

  1. "Start expanded" shows its item on load.
  2. Tap "Expandable list item": it opens to show both items, with the next header right below them.
  3. Tap it again: it closes and the items disappear.
  4. Tap it twice quickly: it ends closed. Open it, then tap twice quickly: it ends open at full height.

Known limitation: a collapse that ends outside act still logs the warning, since the content unmounts after the animation (in List.AccordionGroup too).

The end of the expand animation set React state from Reanimated's
completion callback, outside act, so expanding an accordion in a test
logged an act warning. The expanded layout (auto height, no clipping)
is now applied on the UI thread when the animation reaches its end;
only a finished collapse still updates state, to unmount the content.
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Found potential problems with the pull request:

  • Screenshot or video evidence is missing. Make sure to include one if it affects the UI.

@Doberjohn Doberjohn added this to the 6.0.0 milestone Dec 4, 2026

@Doberjohn Doberjohn left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two things before I approve:

  1. Which platforms did you run the test plan on? overflow and position now switch inside the animated style instead of a regular style, so a quick run on Android, iOS and web would cover the switch at the end of an expand, and the quick double taps.
  2. As your description says, a collapse that ends outside act still logs the warning, since the content unmounts when the collapse ends. Before the accordion animated, a collapse in a test logged nothing, so that half is still open. I'm fine with handling it in a follow-up. If you see a way to keep that state update out of the animation's end as well, it can go here.

@akysil

akysil commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author
  1. I ran the test plan on Android (emulator, release build of the example app) and on web (the example app's web build, in Chromium). All four steps behave as described on both, including the quick double taps: a double tap from closed ends closed, and from open ends open at full height with the next header right below. I couldn't run it on iOS, since I don't have an iOS build setup.
  2. I'd keep the collapse for a follow-up. A collapse can only skip that state update if the content either stays mounted after it closes, which changes what's rendered and what screen readers find, or unmounts as the collapse starts and animates out with a layout animation, which moves the height animation off the current approach. Either is a bigger change than this PR.

This branch has not been deployed

No deployments
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.

List.Accordion: expanding it in a test logs "An update to List.Accordion inside a test was not wrapped in act(...)"

2 participants