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', () => {
297
297
298
298
cy . findByRole ( 'tab' , { name : / T a b 1 / i } ) . should ( 'have.focus' ) ;
299
299
} ) ;
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
+ } ) ;
300
314
} ) ;
301
315
302
316
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';
18
18
/**
19
19
* TABS TODOs
20
20
*
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
28
22
29
23
*
30
24
* aria Tabs Pattern https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
@@ -162,7 +156,7 @@ export const Tabs = component$((props: TabsProps) => {
162
156
) ;
163
157
164
158
if (
165
- key === KeyCode . ArrowRight ||
159
+ ( ! props . vertical && key === KeyCode . ArrowRight ) ||
166
160
( props . vertical && key === KeyCode . ArrowDown )
167
161
) {
168
162
let nextTabId = enabledTabs [ 0 ] . tabId ;
@@ -174,7 +168,7 @@ export const Tabs = component$((props: TabsProps) => {
174
168
}
175
169
176
170
if (
177
- key === KeyCode . ArrowLeft ||
171
+ ( ! props . vertical && key === KeyCode . ArrowLeft ) ||
178
172
( props . vertical && key === KeyCode . ArrowUp )
179
173
) {
180
174
let previousTabId = enabledTabs [ enabledTabs . length - 1 ] . tabId ;
@@ -215,7 +209,7 @@ export const Tabs = component$((props: TabsProps) => {
215
209
reIndexTabs$,
216
210
onTabKeyDown$,
217
211
selectIfAutomatic$,
218
- selectedClassName : props . selectedClassName
212
+ selectedClassName : props . selectedClassName ,
219
213
} ;
220
214
221
215
useContextProvider ( tabsContextId , contextService ) ;
You can’t perform that action at this time.
0 commit comments