fix(react-ui): don't auto-select the last tab on Tabs initial mount#820
Open
Shinyaigeek wants to merge 1 commit into
Open
fix(react-ui): don't auto-select the last tab on Tabs initial mount#820Shinyaigeek wants to merge 1 commit into
Shinyaigeek wants to merge 1 commit into
Conversation
The dependency-less auto-advance effect in Tabs treats every tab as "grown" on its first pass (prevContentSizes starts empty), so candidate ends the loop at the last item and overrides the first-tab default set by the mount effect in the same commit. A static three-tab response therefore mounts with the last tab active instead of the first. Record the first pass as a baseline only and skip candidate selection. Streaming follow-along is unaffected: content growth relative to the baseline, or a tab appearing after the first pass, still advances the active tab. Fixes thesysdev#819 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.
Fixes #819
Problem
<Tabs>selects the last tab on initial mount instead of the first, even for a fully static (non-streaming) response.Standalone repro against the published packages: https://github.com/Shinyaigeek/openui-tabs-repro
The dependency-less auto-advance effect (streaming follow-along) runs its first pass with
prevContentSizes.currentempty, so every tab satisfiessize > prevSizeandcandidateends the loop at the last item. It runs in the same commit as — and after — the effect that defaultsactiveTabto the first tab, so the last tab wins.Fix
Treat the first pass as a baseline-recording pass: record
nextSizesbut skip candidate selection whenprevContentSizes.currentis empty.Streaming follow-along is unaffected:
Verification
Rendered via a vite harness aliased to
react-uisource, before/after:Before:
After (top: static mount now Apple; bottom: streaming control still ends on Cherry):
pnpm test(react-ui): 13 passed.lint:check: 0 errors.typecheckfailures inUserMessageContent.tsx/index.tsare pre-existing onmain(verified by stashing this change).🤖 Generated with Claude Code