File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
packages/kit-headless/src/components/tabs Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,20 @@ describe('Tabs', () => {
297297
298298 cy . findByRole ( 'tab' , { name : / T a b 1 / i } ) . should ( 'have.focus' ) ;
299299 } ) ;
300+
301+ it ( `GIVEN 3 vertical tabs and the focus is on the first,
302+ WHEN triggering the right arrow key or left arrow key
303+ THEN the focus should stay on the first tab` , ( ) => {
304+ cy . mount ( < ThreeTabsComponent isVertical = { true } /> ) ;
305+
306+ cy . findByRole ( 'tab' , { name : / T a b 1 / i } ) . type ( '{rightarrow}' ) ;
307+
308+ cy . findByRole ( 'tab' , { name : / T a b 1 / i } ) . should ( 'have.focus' ) ;
309+
310+ cy . findByRole ( 'tab' , { name : / T a b 1 / i } ) . type ( '{leftarrow}' ) ;
311+
312+ cy . findByRole ( 'tab' , { name : / T a b 1 / i } ) . should ( 'have.focus' ) ;
313+ } ) ;
300314 } ) ;
301315
302316 describe ( 'UP key handling' , ( ) => {
Original file line number Diff line number Diff line change @@ -18,13 +18,7 @@ import { KeyCode } from '../../utils/key-code.type';
1818/**
1919 * TABS TODOs
2020 *
21- * Missing 'code' section implementation:
22- * - Vertical
23- * - disabled
24- * - dynamic
25- * - behavior
26- * - onSelectedIndexChange$
27- * - onClick$
21+ * Create a test for arrow right and left and make sure it works only in horizontal mode
2822
2923 *
3024* aria Tabs Pattern https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
@@ -162,7 +156,7 @@ export const Tabs = component$((props: TabsProps) => {
162156 ) ;
163157
164158 if (
165- key === KeyCode . ArrowRight ||
159+ ( ! props . vertical && key === KeyCode . ArrowRight ) ||
166160 ( props . vertical && key === KeyCode . ArrowDown )
167161 ) {
168162 let nextTabId = enabledTabs [ 0 ] . tabId ;
@@ -174,7 +168,7 @@ export const Tabs = component$((props: TabsProps) => {
174168 }
175169
176170 if (
177- key === KeyCode . ArrowLeft ||
171+ ( ! props . vertical && key === KeyCode . ArrowLeft ) ||
178172 ( props . vertical && key === KeyCode . ArrowUp )
179173 ) {
180174 let previousTabId = enabledTabs [ enabledTabs . length - 1 ] . tabId ;
@@ -215,7 +209,7 @@ export const Tabs = component$((props: TabsProps) => {
215209 reIndexTabs$,
216210 onTabKeyDown$,
217211 selectIfAutomatic$,
218- selectedClassName : props . selectedClassName
212+ selectedClassName : props . selectedClassName ,
219213 } ;
220214
221215 useContextProvider ( tabsContextId , contextService ) ;
You can’t perform that action at this time.
0 commit comments