Skip to content

Commit 21b4d0d

Browse files
committed
test: prevent focus on empty tab panel
1 parent 9a98cd2 commit 21b4d0d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/accessibility.test.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,16 @@ describe('Tabs.Accessibility', () => {
268268
const firstTab = getByRole('tab', { name: /Tab1/i });
269269
expect(firstTab).toHaveFocus();
270270
});
271+
272+
it('should not focus on tab panel when it is empty', async () => {
273+
const user = userEvent.setup();
274+
const { getByRole } = render(
275+
<Tabs defaultActiveKey="1" items={[{ key: '1', label: 'Tab1', children: null }]} />,
276+
);
277+
278+
const tabPanel = getByRole('tabpanel', { name: /Tab1/i });
279+
await user.tab();
280+
await user.tab();
281+
expect(tabPanel).not.toHaveFocus();
282+
});
271283
});

0 commit comments

Comments
 (0)