Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/react-ui/src/genui-lib/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ export const Tabs = defineComponent({
React.useEffect(() => {
if (userHasInteracted.current) return;

// On the first pass every tab satisfies `size > 0`, which would make
// `candidate` end up as the LAST tab and override the first-tab default
// above. Only record the baseline sizes; growth relative to this
// baseline (or a tab appearing later) still auto-advances.
const isBaselinePass = Object.keys(prevContentSizes.current).length === 0;

let candidate: string | null = null;
const nextSizes: Record<string, number> = {};

Expand All @@ -56,6 +62,8 @@ export const Tabs = defineComponent({

prevContentSizes.current = nextSizes;

if (isBaselinePass) return;

if (candidate && candidate !== activeTab) {
setActiveTab(candidate);
}
Expand Down
Loading