feat: crypto dropdown should stay open when editing commissions

This commit is contained in:
Sérgio Salgado 2021-03-16 13:28:38 +00:00 committed by Josh Harvey
parent bee2dc42e6
commit 7af8079a2a
3 changed files with 8 additions and 2 deletions

View file

@ -14,6 +14,7 @@ const Autocomplete = ({
multiple, multiple,
onChange, onChange,
labelProp, labelProp,
shouldStayOpen,
value: outsideValue, value: outsideValue,
error, error,
fullWidth, fullWidth,

View file

@ -21,6 +21,7 @@ const AutocompleteFormik = ({ options, onChange, ...props }) => {
} }
const onChangeHandler = value => setFieldValue(name, value) const onChangeHandler = value => setFieldValue(name, value)
const shouldStayOpen = !!props.shouldStayOpen
return ( return (
<Autocomplete <Autocomplete
@ -38,7 +39,10 @@ const AutocompleteFormik = ({ options, onChange, ...props }) => {
if (!props.multiple) return setOpen(true) if (!props.multiple) return setOpen(true)
setOpen(value?.length !== props.limit) setOpen(value?.length !== props.limit)
}} }}
onClose={() => setOpen(false)} onClose={(event, reason) => {
if (shouldStayOpen && reason !== 'blur') setOpen(true)
else setOpen(false)
}}
{...props} {...props}
/> />
) )

View file

@ -103,7 +103,8 @@ const getOverridesFields = (getData, currency, auxElements) => {
valueProp: 'code', valueProp: 'code',
labelProp: 'display', labelProp: 'display',
multiple: true, multiple: true,
onChange: onCryptoChange onChange: onCryptoChange,
shouldStayOpen: true
} }
}, },
{ {