@@ -6,7 +6,9 @@ import { unstable_capitalize as capitalize } from '@mui/utils';
6
6
import composeClasses from '@mui/base/composeClasses' ;
7
7
import { ListItemButtonRoot } from '../ListItemButton/ListItemButton' ;
8
8
import { styled , useThemeProps } from '../styles' ;
9
- import { getAutocompleteOptionUtilityClass } from './autocompleteOptionClasses' ;
9
+ import autocompleteOptionClasses , {
10
+ getAutocompleteOptionUtilityClass ,
11
+ } from './autocompleteOptionClasses' ;
10
12
import { AutocompleteOptionOwnerState , AutocompleteOptionTypeMap } from './AutocompleteOptionProps' ;
11
13
12
14
const useUtilityClasses = ( ownerState : AutocompleteOptionOwnerState ) => {
@@ -28,12 +30,20 @@ export const AutocompleteOptionRoot = styled(ListItemButtonRoot as unknown as 'l
28
30
slot : 'Root' ,
29
31
overridesResolver : ( props , styles ) => styles . root ,
30
32
} ) < { ownerState : AutocompleteOptionOwnerState } > ( ( { theme, ownerState } ) => ( {
33
+ '&:not(:hover)' : {
34
+ transition : 'none' , // prevent flicker when using keyboard arrows to move between options
35
+ } ,
31
36
'&[aria-disabled="true"]' : theme . variants [ `${ ownerState . variant ! } Disabled` ] ?. [ ownerState . color ! ] ,
32
37
'&[aria-selected="true"]' : {
33
38
color : theme . vars . palette . primary . softColor ,
34
39
backgroundColor : theme . vars . palette . primary . softBg ,
35
40
fontWeight : theme . vars . fontWeight . md ,
36
41
} ,
42
+ [ `&.${ autocompleteOptionClasses . focused } :not([aria-selected="true"]):not(:hover)` ] : {
43
+ // create the focused style similar to the hover state
44
+ backgroundColor :
45
+ theme . variants [ `${ ownerState . variant ! } Hover` ] ?. [ ownerState . color ! ] ?. backgroundColor ,
46
+ } ,
37
47
} ) ) ;
38
48
39
49
const AutocompleteOption = React . forwardRef ( function AutocompleteOption ( inProps , ref ) {
0 commit comments