From b6268bd3e4d3c5ccff431d6cee2cd712dc737362 Mon Sep 17 00:00:00 2001 From: stdavis Date: Fri, 3 Mar 2023 10:42:16 -0700 Subject: [PATCH] fix: keep combobox empty on tab --- _src/react-app/components/ComboBox.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/_src/react-app/components/ComboBox.jsx b/_src/react-app/components/ComboBox.jsx index 46da1f5..ff0b832 100644 --- a/_src/react-app/components/ComboBox.jsx +++ b/_src/react-app/components/ComboBox.jsx @@ -18,10 +18,13 @@ const ComboBox = React.forwardRef(function ComboBox({ items, onChange, value, id }, itemToString: (item) => (item ? item.label : ''), selectedItem: items.filter((item) => item.value === value)[0] || '', - stateReducer: (_, actionAndChanges) => { + stateReducer: (state, actionAndChanges) => { const { type, changes } = actionAndChanges; - // clear input on blur if there is no selected item - if (type === useCombobox.stateChangeTypes.InputBlur && changes.inputValue !== changes.selectedItem?.label) { + // clear input on blur if there is no selected item or if the input value is empty + if ( + type === useCombobox.stateChangeTypes.InputBlur && + (changes.inputValue !== changes.selectedItem?.label || state.inputValue === '') + ) { setInputItems(items); return { ...changes,