File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
apps/website/src/routes/docs/headless/select
packages/kit-headless/src/components/select Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,21 @@ test.describe('Keyboard Behavior', () => {
495
495
const highlightedOpt = getRoot ( ) . locator ( '[data-highlighted]' ) ;
496
496
await expect ( highlightedOpt ) . toContainText ( 'jessie' , { ignoreCase : true } ) ;
497
497
} ) ;
498
+
499
+ test ( `GIVEN an open select with a typeahead support
500
+ WHEN the user types in the letters "jjt"
501
+ THEN the first option starting with the letter "t" should have data-highlighted` , async ( {
502
+ page,
503
+ } ) => {
504
+ const { getRoot, getTrigger, openListbox } = await setup (
505
+ page ,
506
+ 'select-typeahead-test' ,
507
+ ) ;
508
+ await openListbox ( 'ArrowDown' ) ;
509
+ await getTrigger ( ) . pressSequentially ( 'jjt' , { delay : 250 } ) ;
510
+ const highlightedOpt = getRoot ( ) . locator ( '[data-highlighted]' ) ;
511
+ await expect ( highlightedOpt ) . toContainText ( 'tim' , { ignoreCase : true } ) ;
512
+ } ) ;
498
513
} ) ;
499
514
} ) ;
500
515
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ export function useTypeahead() {
27
27
return null ;
28
28
}
29
29
if ( indexDiffSig . value === undefined ) {
30
- console . log ( 'Is key length 1?' , charIndex ) ;
31
30
indexDiffSig . value = charIndex + 1 ;
32
31
context . highlightedIndexSig . value = charIndex ;
33
32
return ;
@@ -45,11 +44,18 @@ export function useTypeahead() {
45
44
context . highlightedIndexSig . value = nextIndex ;
46
45
indexDiffSig . value = nextIndex + 1 ;
47
46
}
47
+ return ;
48
48
}
49
+ indexDiffSig . value = charIndex + 1 ;
50
+ context . highlightedIndexSig . value = charIndex ;
49
51
50
52
return ;
51
53
} ) ;
52
54
55
+ const multipleChars$ = $ ( ( ) => {
56
+ // If multiple keys are typed in quick succession, visual focus moves to the first option that matches the full string.
57
+ } ) ;
58
+
53
59
firstCharOnly$ ( ) ;
54
60
} ) ;
55
61
You can’t perform that action at this time.
0 commit comments