Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/TabNavList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ const TabNavList = React.forwardRef<HTMLDivElement, TabNavListProps>((props, ref
case 'Enter':
case 'Space': {
e.preventDefault();
onTabClick(focusKey, e);
onTabClick(activeKey, e);
break;
}
// Backspace
Expand Down
5 changes: 4 additions & 1 deletion tests/accessibility.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,26 @@ describe('Tabs.Accessibility', () => {

it('should activate tab on Enter/Space', async () => {
const onTabClick = jest.fn();
const onChange = jest.fn();
const user = userEvent.setup();

render(createTabs({ onTabClick }));
render(createTabs({ onTabClick, onChange }));

// jump to first tab
await user.tab();

// activate tab
await user.keyboard(' ');
expect(onTabClick).toHaveBeenCalledTimes(1);
expect(onChange).not.toHaveBeenCalled();

// move focus to second tab
await user.keyboard('{ArrowRight}');

// activate tab
await user.keyboard('{Enter}');
expect(onTabClick).toHaveBeenCalledTimes(2);
expect(onChange).not.toHaveBeenCalled();
});

it('should not navigate to disabled tabs', async () => {
Expand Down