Skip to content

Commit

Permalink
fix(ComboBox): save onInputChange in ref
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Apr 30, 2021
1 parent 7eaad2b commit 8f4df8b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/react/src/components/ComboBox/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const ComboBox = (props) => {
);
const [prevSelectedItem, setPrevSelectedItem] = useState(null);
const [doneInitialSelectedItem, setDoneInitialSelectedItem] = useState(null);
const { current: handleInputChange } = useRef(onInputChange);

if (!doneInitialSelectedItem || prevSelectedItem !== selectedItem) {
setDoneInitialSelectedItem(true);
Expand Down Expand Up @@ -147,10 +148,10 @@ const ComboBox = (props) => {
};

useEffect(() => {
if (onInputChange) {
onInputChange(inputValue);
if (handleInputChange) {
handleInputChange(inputValue);
}
}, [onInputChange, inputValue]);
}, [handleInputChange, inputValue]);

const handleSelectionClear = () => {
if (textInput?.current) {
Expand Down

0 comments on commit 8f4df8b

Please sign in to comment.