File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
packages/kit-headless/src/components/Autocomplete Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -433,7 +433,10 @@ export const AutocompleteListbox = component$((props: ListboxProps) => {
433
433
) ;
434
434
} ) ;
435
435
436
- export type OptionProps = { optionValue : string } & QwikIntrinsicElements [ 'li' ] ;
436
+ export type OptionProps = {
437
+ optionValue : string ;
438
+ disabled ?: boolean ;
439
+ } & QwikIntrinsicElements [ 'li' ] ;
437
440
438
441
export const AutocompleteOption = component$ ( ( props : OptionProps ) => {
439
442
const ref = useSignal < HTMLElement > ( ) ;
@@ -445,16 +448,20 @@ export const AutocompleteOption = component$((props: OptionProps) => {
445
448
< li
446
449
ref = { ref }
447
450
role = "option"
451
+ tabIndex = { props . disabled ? - 1 : 0 }
452
+ aria-disabled = { props . disabled }
448
453
onClick$ = { [
449
454
$ ( ( ) => {
450
- contextService . inputValue . value = props . optionValue ;
451
- contextService . isExpanded . value = false ;
455
+ if ( ! props . disabled ) {
456
+ contextService . inputValue . value = props . optionValue ;
457
+ contextService . isExpanded . value = false ;
458
+ }
452
459
} ) ,
453
460
props . onClick$ ,
454
461
] }
455
462
onKeyDown$ = { [
456
463
$ ( ( e : QwikKeyboardEvent ) => {
457
- if ( e . key === 'Enter' || e . key === ' ' ) {
464
+ if ( ( e . key === 'Enter' || e . key === ' ' ) && ! props . disabled ) {
458
465
contextService . inputValue . value = props . optionValue ;
459
466
contextService . isExpanded . value = false ;
460
467
const inputElement = contextService . triggerRef . value
@@ -464,7 +471,6 @@ export const AutocompleteOption = component$((props: OptionProps) => {
464
471
} ) ,
465
472
props . onKeyDown$ ,
466
473
] }
467
- tabIndex = { 0 }
468
474
{ ...props }
469
475
>
470
476
< Slot />
You can’t perform that action at this time.
0 commit comments