Skip to content

Commit

Permalink
forward more events
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Nov 10, 2019
1 parent 6c9a852 commit 2eee26b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default function useAutocomplete(props) {

const [focused, setFocused] = React.useState(false);

const resetInputValue = useEventCallback(newValue => {
const resetInputValue = useEventCallback((event, newValue) => {
let newInputValue;
if (multiple) {
newInputValue = '';
Expand Down Expand Up @@ -202,12 +202,12 @@ export default function useAutocomplete(props) {
setInputValue(newInputValue);

if (onInputChange) {
onInputChange(null, newInputValue);
onInputChange(event, newInputValue);
}
});

React.useEffect(() => {
resetInputValue(value);
resetInputValue(null, value);
}, [value, resetInputValue]);

const { current: isOpenControlled } = React.useRef(openProp != null);
Expand Down Expand Up @@ -413,7 +413,7 @@ export default function useAutocomplete(props) {
handleClose(event);
}

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

selectedIndexRef.current = -1;
};
Expand Down Expand Up @@ -599,7 +599,7 @@ export default function useAutocomplete(props) {
if (autoSelect && selectedIndexRef.current !== -1) {
handleValue(event, filteredOptions[selectedIndexRef.current]);
} else if (!freeSolo) {
resetInputValue(value);
resetInputValue(event, value);
}

handleClose(event);
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/utils/useEventCallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export default function useEventCallback(fn) {
useEnhancedEffect(() => {
ref.current = fn;
});
return React.useCallback(event => (0, ref.current)(event), []);
return React.useCallback((...args) => (0, ref.current)(...args), []);
}

0 comments on commit 2eee26b

Please sign in to comment.