Skip to content

Commit 02d2ebd

Browse files
committed
Revert to initialSelectedIndex prop
1 parent a8ba962 commit 02d2ebd

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packages/circuit-ui/components/Tabs/Tabs.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('Tabs', () => {
7373
it('should go to the previous tab on left arrow press', async () => {
7474
render(
7575
<Tabs
76-
initialSelectedId="b"
76+
initialSelectedIndex={1}
7777
items={[
7878
{ id: 'a', tab: 'tab-a', panel: 'panel-a' },
7979
{ id: 'b', tab: 'tab-b', panel: 'panel-b' },

packages/circuit-ui/components/Tabs/Tabs.tsx

+5-9
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import { TabPanel } from './components/TabPanel/index.js';
2929

3030
export interface TabsProps extends TabListProps {
3131
/**
32-
* The id of the initially selected tab.
32+
* The index of the initially selected tab.
3333
*
34-
* @default items[0].id
34+
* @default 0
3535
*/
36-
initialSelectedId?: string;
36+
initialSelectedIndex?: number;
3737
/**
3838
* A collection of tabs with an id, the tab label, and panel content.
3939
*/
@@ -44,12 +44,8 @@ export interface TabsProps extends TabListProps {
4444
}[];
4545
}
4646

47-
export function Tabs({
48-
items,
49-
initialSelectedId = items[0].id,
50-
...props
51-
}: TabsProps) {
52-
const [selectedId, setSelectedId] = useState(initialSelectedId);
47+
export function Tabs({ items, initialSelectedIndex = 0, ...props }: TabsProps) {
48+
const [selectedId, setSelectedId] = useState(items[initialSelectedIndex]?.id);
5349

5450
const handleTabKeyDown = (event: KeyboardEvent) => {
5551
const selectedIndex = items.findIndex((item) => item.id === selectedId);

0 commit comments

Comments
 (0)