Skip to content

Commit

Permalink
Add missing pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongarciah committed Jul 4, 2024
1 parent b2dc86d commit d6199f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/mui-base/src/useAutocomplete/useAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function useAutocomplete(props) {
const [focused, setFocused] = React.useState(false);

const resetInputValue = React.useCallback(
(event, newValue) => {
(event, newValue, reason) => {
// retain current `inputValue` if new option isn't selected and `clearOnBlur` is false
// When `multiple` is enabled, `newValue` is an array of all selected items including the newly selected item
const isOptionSelected = multiple ? value.length < newValue.length : newValue !== null;
Expand All @@ -176,7 +176,7 @@ export function useAutocomplete(props) {
setInputValueState(newInputValue);

if (onInputChange) {
onInputChange(event, newInputValue, 'reset');
onInputChange(event, newInputValue, reason);
}
},
[getOptionLabel, inputValue, multiple, onInputChange, setInputValueState, clearOnBlur, value],
Expand Down Expand Up @@ -681,7 +681,7 @@ export function useAutocomplete(props) {
}
}

resetInputValue(event, newValue);
resetInputValue(event, newValue, reason);

handleValue(event, newValue, reason, { option });
if (!disableCloseOnSelect && (!event || (!event.ctrlKey && !event.metaKey))) {
Expand Down Expand Up @@ -939,7 +939,7 @@ export function useAutocomplete(props) {
} else if (autoSelect && freeSolo && inputValue !== '') {
selectNewValue(event, inputValue, 'blur', 'freeSolo');
} else if (clearOnBlur) {
resetInputValue(event, value);
resetInputValue(event, value, 'blur');
}

handleClose(event, 'blur');
Expand Down

0 comments on commit d6199f9

Please sign in to comment.