File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
apps/website/src/routes/docs/headless/select
packages/kit-headless/src/components/select Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,21 @@ test.describe('Keyboard Behavior', () => {
171
171
await expect ( getListbox ( ) ) . toBeHidden ( ) ;
172
172
await expect ( getTrigger ( ) ) . toHaveAttribute ( 'aria-expanded' , 'false' ) ;
173
173
} ) ;
174
+
175
+ test ( `GIVEN a hero select with an opened listbox
176
+ WHEN focusing something outside of the hero select's trigger
177
+ THEN the listbox should close
178
+ AND aria-expanded should be false` , async ( { page } ) => {
179
+ const { getTrigger, getListbox, openListbox } = await setup (
180
+ page ,
181
+ 'select-hero-test' ,
182
+ ) ;
183
+
184
+ await openListbox ( 'Enter' ) ;
185
+ await getTrigger ( ) . press ( 'Tab' ) ;
186
+ await expect ( getListbox ( ) ) . toBeHidden ( ) ;
187
+ await expect ( getTrigger ( ) ) . toHaveAttribute ( 'aria-expanded' , 'false' ) ;
188
+ } ) ;
174
189
} ) ;
175
190
176
191
test . describe ( 'data-highlighted navigation' , ( ) => {
Original file line number Diff line number Diff line change @@ -74,12 +74,17 @@ export const SelectTrigger = component$<SelectTriggerProps>((props) => {
74
74
}
75
75
} ) ;
76
76
77
+ const handleBlur$ = $ ( ( ) => {
78
+ context . isListboxOpenSig . value = false ;
79
+ } ) ;
80
+
77
81
return (
78
82
< button
79
83
{ ...props }
80
84
ref = { context . triggerRef }
81
85
onClick$ = { [ handleClick$ , props . onClick$ ] }
82
86
onKeyDown$ = { [ handleKeyDownSync$ , handleKeyDown$ , props . onKeyDown$ ] }
87
+ onBlur$ = { [ handleBlur$ , props . onBlur$ ] }
83
88
data-open = { context . isListboxOpenSig . value ? '' : undefined }
84
89
data-closed = { ! context . isListboxOpenSig . value ? '' : undefined }
85
90
aria-expanded = { context . isListboxOpenSig . value }
You can’t perform that action at this time.
0 commit comments