Skip to content

Commit 92ae8c8

Browse files
committed
fix(headless/tabs): disabled edges working now
1 parent c155a0f commit 92ae8c8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/kit-headless/src/components/tabs/tabs.spec.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,26 @@ describe('Tabs', () => {
527527
cy.findByRole('tab', { name: /Tab 3/i }).should('have.focus');
528528
});
529529

530+
it(`GIVEN 3 horizontal tabs with the first one disabled and last one is focused
531+
WHEN triggering the right arrow key
532+
THEN the focus should be on the second tab`, () => {
533+
cy.mount(<PotentiallyDisabledThreeTabs disabledIndex={0} />);
534+
535+
cy.findByRole('tab', { name: /Tab 3/i }).type('{rightarrow}');
536+
537+
cy.findByRole('tab', { name: /Tab 2/i }).should('have.focus');
538+
});
539+
540+
it(`GIVEN 3 horizontal tabs with the first one disabled and last one is focused
541+
WHEN triggering the right arrow key
542+
THEN the focus should be on the second tab`, () => {
543+
cy.mount(<PotentiallyDisabledThreeTabs disabledIndex={2} />);
544+
545+
cy.findByRole('tab', { name: /Tab 2/i }).type('{rightarrow}');
546+
547+
cy.findByRole('tab', { name: /Tab 1/i }).should('have.focus');
548+
});
549+
530550
it(`GIVEN 3 tabs and the last is disabled and the focus is on the first,
531551
WHEN triggering the 'end' key
532552
THEN the focus should be on the second tab`, () => {

packages/kit-headless/src/components/tabs/tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export const Tabs = component$((props: TabsProps) => {
159159
) {
160160
let nextTabId = enabledTabs[0].tabId;
161161

162-
if (currentFocusedTabIndex < tabPairsList.length - 1) {
162+
if (currentFocusedTabIndex < enabledTabs.length - 1) {
163163
nextTabId = enabledTabs[currentFocusedTabIndex + 1].tabId;
164164
}
165165
focusOnTab(nextTabId);

0 commit comments

Comments
 (0)