Skip to content

Commit ebee7c1

Browse files
committed
test(headless/tabs): handling enter key
1 parent 90f9f3d commit ebee7c1

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,19 @@ describe('Tabs', () => {
365365
});
366366
});
367367

368-
it.only(`GIVEN 3 tabs
369-
WHEN clicking the first one and triggering the right arrow key
370-
THEN render the middle panel`, () => {
371-
cy.mount(<ThreeTabsComponent />);
368+
describe.skip('Manual behavior', () => {
369+
it(`GIVEN 3 tabs
370+
WHEN clicking the first one and triggering the right arrow key and then "enter"
371+
THEN the middle panel should be selected`, () => {
372+
cy.mount(<ThreeTabsComponent />);
372373

373-
cy.findByRole('tab', { name: /Tab 1/i }).click();
374+
cy.findByRole('tab', { name: /Tab 1/i })
375+
.click()
376+
.type('{rightarrow}')
377+
.type('{enter}');
374378

375-
cy.findByRole('tabpanel').should('contain', 'Panel 2');
379+
cy.findByRole('tabpanel').should('contain', 'Panel 2');
380+
});
376381
});
377382
});
378383

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ export const Tabs = component$((props: TabsProps) => {
159159
(tabPair) => tabPair.tabId === currentTabId
160160
);
161161

162+
if (key === KeyCode.Enter) {
163+
}
164+
162165
if (
163166
key === KeyCode.ArrowRight ||
164167
(props.vertical && key === KeyCode.ArrowDown)

packages/kit-headless/src/utils/key-code.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export enum KeyCode {
77
End = 'End',
88
PageUp = 'PageUp',
99
PageDown = 'PageDown',
10+
Enter = 'Enter',
1011
}

0 commit comments

Comments
 (0)