Skip to content

Commit

Permalink
persist input values
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Mar 16, 2023
1 parent 5c9ab4c commit 365aa59
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions client/src/components/dialogs/import/Nominatim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ export default function Nominatim({
)
}}
inputValue={inputValue}
onInputChange={(_e, newInputValue) => {
setInputValue(newInputValue)
onInputChange={(e, newInputValue) => {
if (e && e.type !== 'click') {
setInputValue(newInputValue)
}
}}
renderInput={(params) => (
<TextField
Expand Down
11 changes: 9 additions & 2 deletions client/src/components/drawer/inputs/Instance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function InstanceSelect({
)
const [loading, setLoading] = React.useState(false)
const [selected, setSelected] = React.useState<KojiKey[]>([])
const [inputValue, setInputValue] = React.useState('')

React.useEffect(() => {
if (controlled) setSelected(initialState)
Expand Down Expand Up @@ -166,13 +167,19 @@ export default function InstanceSelect({
>
<Autocomplete
value={selected}
inputValue={inputValue}
size="small"
onChange={(_e, newValue) => updateState(newValue as KojiKey[])}
filterOptions={filterOptions}
loading={loading}
onChange={(_e, newValue) => updateState(newValue as KojiKey[])}
onInputChange={(e, newInputValue) => {
if (e && e.type !== 'click') {
setInputValue(newInputValue)
}
}}
selectOnFocus
clearOnBlur
multiple
loading={loading}
handleHomeEndKeys
disableCloseOnSelect
fullWidth
Expand Down
7 changes: 7 additions & 0 deletions client/src/components/drawer/inputs/SelectProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function SelectProject({

const [loading, setLoading] = React.useState(false)
const [selected, setSelected] = React.useState<string[]>([])
const [inputValue, setInputValue] = React.useState('')

const filterOptions = createFilterOptions({
matchFrom: 'any',
Expand Down Expand Up @@ -103,7 +104,13 @@ export default function SelectProject({
<ListItem key={Object.keys(options).join('')} sx={{ py: 1 }}>
<Autocomplete
size="small"
inputValue={inputValue}
onChange={(_e, newValue) => newValue && updateState(newValue)}
onInputChange={(e, newInputValue) => {
if (e && e.type !== 'click') {
setInputValue(newInputValue)
}
}}
value={selected}
filterOptions={filterOptions}
selectOnFocus
Expand Down

0 comments on commit 365aa59

Please sign in to comment.