fix for single selects with values selected

This commit is contained in:
sektordv 2021-08-12 11:00:49 +02:00
parent bb890fa5f0
commit 22210564e7

View file

@ -105,8 +105,8 @@ const SingleAutocompleteSelectFieldComponent: React.FC<SingleAutocompleteSelectF
selectedItem={value || ""} selectedItem={value || ""}
// this is to prevent unwanted state updates when the dropdown is closed with an empty value, // this is to prevent unwanted state updates when the dropdown is closed with an empty value,
// which downshift interprets as the value being updated with an empty string, causing side-effects // which downshift interprets as the value being updated with an empty string, causing side-effects
stateReducer={(state, changes) => { stateReducer={(_, changes) => {
if (changes.isOpen === false && state.inputValue === "") { if (changes.isOpen === false) {
delete changes.inputValue; delete changes.inputValue;
} }
return changes; return changes;
@ -210,6 +210,7 @@ const SingleAutocompleteSelectFieldComponent: React.FC<SingleAutocompleteSelectF
FormHelperTextProps={FormHelperTextProps} FormHelperTextProps={FormHelperTextProps}
label={label} label={label}
fullWidth={true} fullWidth={true}
onBlur={onBlur}
/> />
{isOpen && (!!inputValue || !!choices.length) && ( {isOpen && (!!inputValue || !!choices.length) && (
<SingleAutocompleteSelectFieldContent <SingleAutocompleteSelectFieldContent