From 2eee26b60d74d9983547c4f6259a3f4a2d012f65 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 10 Nov 2019 13:04:57 +0100 Subject: [PATCH] forward more events --- .../src/useAutocomplete/useAutocomplete.js | 10 +++++----- packages/material-ui/src/utils/useEventCallback.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js index 475262743c19bd..5de91aaa427c7f 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js @@ -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 = ''; @@ -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); @@ -413,7 +413,7 @@ export default function useAutocomplete(props) { handleClose(event); } - resetInputValue(newValue); + resetInputValue(event, newValue); selectedIndexRef.current = -1; }; @@ -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); diff --git a/packages/material-ui/src/utils/useEventCallback.js b/packages/material-ui/src/utils/useEventCallback.js index 73f861ff0034f4..733cc3693badbb 100644 --- a/packages/material-ui/src/utils/useEventCallback.js +++ b/packages/material-ui/src/utils/useEventCallback.js @@ -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), []); }