fix(react-ui): don't auto-open the last Accordion item on initial mount - #862
Open
Shinyaigeek wants to merge 2 commits into
Open
fix(react-ui): don't auto-open the last Accordion item on initial mount#862Shinyaigeek wants to merge 2 commits into
Shinyaigeek wants to merge 2 commits into
Conversation
The auto-open branch in Accordion treats any growth in item count as a new item arriving during streaming. On the baseline render prevItemCount is 0, so a fully static N-item response satisfies the check and opens items[items.length - 1] — the last section — instead of the first (the behavior before the thesysdev#485 refactor removed the first-item mount effect). Record the baseline pass separately and open the FIRST item there; streaming follow-along is unaffected, since an item arriving after the baseline still auto-opens the newest one. Track the auto-opened item by index rather than by value so a value string that is still streaming in re-syncs once it completes, instead of latching a prefix that matches no item and leaving every section closed. Fixes thesysdev#861 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Shinyaigeek
added a commit
to Shinyaigeek/openui-accordion-repro
that referenced
this pull request
Jul 25, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #861 —
<Accordion>opens the last item on initial mount for a fully static (non-streaming) response, instead of the first.The auto-open branch treats any growth in item count as "a new item arrived during streaming". On the baseline render
prevItemCountis0, so a static N-item response satisfiesitems.length > prevItemCount.currentand opensitems[items.length - 1]. This is the same defect shape as the<Tabs>issue #819: a streaming follow-along heuristic that doesn't exclude the initial mount.Changes
prevItemCountnow starts atnullso the very first render is distinguishable from streaming growth. A static mount opens the first section — restoring the behavior from before the refactor(react-ui): simplify Accordion auto-open logic #485 refactor removed the first-item mount effect. Streaming follow-along is unchanged: an item arriving after the baseline still auto-opens the newest one (an accordion that mounts empty mid-stream records a0baseline, so its first item still auto-opens on arrival).valuestring had finished streaming,setOpenItemlatched a prefix of the value (e.g."ov"for"overview"); since the only re-sync trigger was count growth, the completed value never re-synced and every section ended up closed. Tracking the index re-syncsopenItemonce the value completes.Reproduction / verification
Standalone repro against the published packages: https://github.com/Shinyaigeek/openui-accordion-repro
react-ui@0.13.1)Accordion.ssr.test.tsx) that renders the static three-section program through the realRenderer+openuiLibraryand asserts the first section is the open one. It fails on the previous implementation with[ 'false', 'false', 'true' ](last open) and passes with this change.pnpm testinpackages/react-ui: 28 passed.Apple) is open on mount.🤖 Generated with Claude Code