Skip to content

fix(Tabs): drop the Content value prop nothing read, and say when a child is ignored - #42

Merged
thinkclay merged 1 commit into
mainfrom
fix/tabs-content-value-prop
Sep 26, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/tabs-content-value-prop

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Addresses Scaffald/SaaS#906.

TabContentProps declared a value, documented as associating a panel with a trigger "for Radix-style API — when the active tab value matches, this content is shown". Nothing read it. TabContent decides purely on useTabItemContext().isSelected, so a panel written in that shape — a sibling of the triggers rather than nested in its Tabs.Item — rendered nothing.

It was silent as well as wrong. Tabs walks its direct children looking for a TabTrigger among each one's children and keeps the child only if (trigger). A bare Tabs.Content has none, so it was discarded before TabContent ever ran — which is why useTabItemContext's own 'TabItem components must be used within a TabItem' throw never fired. No render, no warning, no DOM. Just a tab strip over empty space.

Four screens in Scaffald/SaaS believed that docstring, including the IPIP share-link page, where the reader is someone outside the account (Scaffald/SaaS#896; call sites fixed in Scaffald/SaaS#899). The prop was the trap, not the call sites — which is why that fix left this open.

Two changes

1. value is gone, so the mistake is a type error at every call site:

error TS2322: Type '{ children: string; value: string; }' is not assignable
  to type 'IntrinsicAttributes & TabContentProps'

A comment stands where it was, explaining what it did and why it isn't coming back — otherwise the next person reads the old docstring in git history and re-adds it.

I went with removing rather than honouring it. Honouring would mean Tabs collecting bare TabContent children and matching on value, which makes the docstring true but leaves two supported shapes to maintain forever. Every example, story and call site already uses the nested form, so the prop only ever added a way to be wrong.

2. The silent discard now warns in development — the root defect. A type error can't catch every case: a Tabs.Content nested one level too deep, or a Tabs.Item with no trigger, both still reach that branch. The warning names what was dropped and shows the shape that works.

Production is unaffected — the warning is behind NODE_ENV !== 'production', and nothing about rendering changed.

Tests

Tabs.droppedChildren.test.tsx:

  • a bare Tabs.Content warns, mentions Tabs.Content and Tabs.Item (a warning that doesn't say what to do is half a warning)
  • it still doesn't render — the warning is the only behaviour change
  • a dropped child that isn't a Tabs.Content is named too
  • the supported nested shape renders the selected panel, hides the other, and stays silent
  • {cond && <Tabs.Item/>} evaluating to false does not warn

That last one is what keeps the warning usable: without it, every conditionally-built tab strip would spam the console and the warning would get ignored — which is how it ends up silent again by another route.

714 passed / 0 failed in this package; tsc --noEmit clean.

Left alone deliberately

  • The noExplicitAny warning biome reports in Tabs.types.ts is pre-existing, on getTriggerProps (line 346 before this change).
  • biome also reports formatting drift in the sibling Tabs files (TabContent.tsx, TabItem.tsx, TabTrigger.tsx, Tabs.styles.ts, index.ts, useTabItem.ts, useTabs.ts). All pre-existing, none of them files this PR touches — folding a reformat of seven files into this diff would bury the two changes that matter.

Needs a submodule pointer bump in Scaffald/SaaS after this merges.

… child is ignored

`TabContentProps` declared a `value`, documented as associating a panel with a
trigger "for Radix-style API — when the active tab value matches, this content
is shown". Nothing read it. `TabContent` decides purely on
`useTabItemContext().isSelected`, so a panel written in that shape — a sibling
of the triggers rather than nested in its `Tabs.Item` — rendered nothing.

It was silent as well as wrong. `Tabs` walks its direct children looking for a
`TabTrigger` among each one's children and keeps the child only
`if (trigger)`; a bare `Tabs.Content` has none, so it was discarded before
`TabContent` ever ran. That is why `useTabItemContext`'s own
"TabItem components must be used within a TabItem" throw never fired: no
render, no warning, no DOM, just a tab strip over empty space.

Four screens in Scaffald/SaaS believed that docstring, including the IPIP
share-link page, where the reader is someone outside the account
(Scaffald/SaaS#896, call sites fixed in Scaffald/SaaS#899). The prop was the
trap, not the call sites.

## Two changes

`value` is gone from `TabContentProps`, so the mistake is now a type error at
every call site:

    error TS2322: Type '{ children: string; value: string; }' is not
    assignable to type 'IntrinsicAttributes & TabContentProps'

A comment stands in its place explaining what it was and why it is not coming
back, so nobody re-adds it from the old docstring.

And the silent discard — the root defect — now warns in development, naming
what was dropped and showing the shape that works. Type errors cannot catch
every case: a `Tabs.Content` nested one level too deep, or a `Tabs.Item` with
no trigger, both still reach that branch.

Production is unaffected: the warning is behind `NODE_ENV !== 'production'`,
and nothing about rendering changed.

## Tests

`Tabs.droppedChildren.test.tsx` covers the bare-Content case warning and still
not rendering, a non-Content dropped child, the supported nested shape staying
silent, and — the one that keeps the warning usable — `{cond && <Tabs.Item/>}`
evaluating to `false` NOT warning, so a conditionally-built strip is not noisy.

714 passed / 0 failed in this package; typecheck clean.

The `noExplicitAny` warning biome reports in Tabs.types.ts is pre-existing on
`getTriggerProps` (line 346 before this change) and untouched here. The
formatting drift biome reports in the sibling Tabs files is also pre-existing
and left alone rather than folded into this diff.

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay merged commit 2f094f7 into main Sep 26, 2026
@thinkclay
thinkclay deleted the fix/tabs-content-value-prop branch September 26, 2026 21:00
thinkclay added a commit to Scaffald/SaaS that referenced this pull request Sep 26, 2026
…#906) (#918)

Scaffald/ui#42 is merged. `TabContentProps.value` is gone — the prop that was
documented as associating a panel with a trigger and that nothing ever read —
so writing `<Tabs.Content value="x">` is now a type error rather than an
element silently discarded before it renders.

`Tabs` also warns in development when it drops a direct child that has no
`Tabs.Trigger` among its children. That is the root defect #906 was about: the
`if (trigger)` branch used to skip such a child with no render, no warning and
no DOM, which is why `useTabItemContext`'s "must be used within a TabItem"
throw never fired and four screens shipped a tab strip over empty space (#896).

No call sites change. #899 already nested every `Tabs.Content` in this repo
inside its `Tabs.Item`, including the fourth site it had missed — the IPIP
share-link page — so `Tabs.Content value=` appears nowhere outside the ui
package's own stories, which use the nested form.

Co-authored-by: Claude Opus 5 <[email protected]>
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.

1 participant