@@ -3,7 +3,11 @@ import PropTypes from 'prop-types';
33import { OverridableComponent } from '@mui/types' ;
44import { chainPropTypes , integerPropType } from '@mui/utils' ;
55import composeClasses from '@mui/base/composeClasses' ;
6- import { useAutocomplete , AutocompleteGroupedOption } from '@mui/base/AutocompleteUnstyled' ;
6+ import {
7+ useAutocomplete ,
8+ AutocompleteGroupedOption ,
9+ UseAutocompleteProps ,
10+ } from '@mui/base/AutocompleteUnstyled' ;
711import PopperUnstyled , {
812 PopperUnstyledProps ,
913 PopperUnstyledTypeMap ,
@@ -190,6 +194,27 @@ const AutocompleteLimitTag = styled('span', {
190194 marginBlockStart : 'var(--_Input-paddingBlock)' ,
191195} ) ;
192196
197+ const excludeUseAutocompleteParams = <
198+ T extends Partial < UseAutocompleteProps < any , undefined , undefined , undefined > > ,
199+ > ( {
200+ autoComplete,
201+ autoHighlight,
202+ autoSelect,
203+ blurOnSelect,
204+ clearOnBlur,
205+ clearOnEscape,
206+ defaultValue,
207+ disableCloseOnSelect,
208+ disabledItemsFocusable,
209+ disableListWrap,
210+ filterSelectedOptions,
211+ handleHomeEndKeys,
212+ includeInputInList,
213+ openOnFocus,
214+ selectOnFocus,
215+ ...other
216+ } : T ) => other as T ;
217+
193218const Autocomplete = React . forwardRef ( function Autocomplete (
194219 inProps ,
195220 ref : React . ForwardedRef < HTMLDivElement > ,
@@ -239,17 +264,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(
239264 value : valueProp ,
240265 ...otherProps
241266 } = props ;
242- const other = { } as typeof otherProps ;
243- ( Object . keys ( otherProps ) as Array < keyof typeof otherProps > ) . forEach ( ( k ) => {
244- if (
245- ! k . match (
246- // Do not spread these props to the root DOM
247- / ^ ( a u t o C o m p l e t e | a u t o H i g h l i g h t | a u t o S e l e c t | b l u r O n S e l e c t | c l e a r O n B l u r | c l e a r O n E s c a p e | d e f a u l t V a l u e | d i s a b l e C l o s e O n S e l e c t | d i s a b l e d I t e m s F o c u s a b l e | d i s a b l e L i s t W r a p | f i l t e r S e l e c t e d O p t i o n s | h a n d l e H o m e E n d K e y s | i n c l u d e I n p u t I n L i s t | o p e n O n F o c u s | s e l e c t O n F o c u s ) $ / ,
248- )
249- ) {
250- other [ k ] = otherProps [ k ] ;
251- }
252- } ) ;
267+ const other = excludeUseAutocompleteParams ( otherProps ) ;
253268
254269 const formControl = React . useContext ( FormControlContext ) ;
255270 const size = inProps . size ?? formControl ?. size ?? sizeProp ;
0 commit comments