Skip to content

Tabs wrapper drops defaultSelectedKey and keeps duplicate underline state #90

Description

@kemuru

File: src/lib/pagination/tabs.tsx

The bug:

function Tabs({ items, ..., defaultSelectedKey, ...props }) {
  const [selectedKey, setSelectedKey] = useState<Key | undefined>(defaultSelectedKey);
  // ...
  return (
    <AriaTabs {...props} onSelectionChange={handleSelection}>

defaultSelectedKey is destructured out of props before the spread, so it never reaches AriaTabs. The wrapper then maintains its own selectedKey state purely to render the underline highlight. Consequences:

Passing only selectedKey: panel is controlled, underline stays at undefined until the user clicks.
Passing only defaultSelectedKey: underline correct, but AriaTabs falls back to its first item (no default).
Every controlled caller has to pass both keys.
External changes to selectedKey (e.g. URL navigation) don't update the underline.
Suggested fix: forward defaultSelectedKey to AriaTabs, drop the wrapper's own state, derive the underline highlight by reading AriaTabs' selected state via TabRenderProps/useTabsContext instead of duplicating it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions