Skip to content

Commit

Permalink
fix on clear
Browse files Browse the repository at this point in the history
  • Loading branch information
isabellafagioli committed Dec 9, 2024
1 parent 414e71a commit 28f7dec
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions react/components/CostCentersAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ const CostCenterAutocomplete = ({ onChange, organizationId }: Props) => {
})
) || []

const handleSearchInputChange = (serachInput: string) => {
setCostCenterTextInput(serachInput)

}
const handleSearchInputChange = (searchInput: string | null) => {

Check failure on line 47 in react/components/CostCentersAutocomplete.tsx

View workflow job for this annotation

GitHub Actions / QE / Lint Node.js

Delete `··`
setCostCenterTextInput(searchInput ?? '')

Check failure on line 48 in react/components/CostCentersAutocomplete.tsx

View workflow job for this annotation

GitHub Actions / QE / Lint Node.js

Replace `··setCostCenterTextInput(searchInput·??·'')·` with `setCostCenterTextInput(searchInput·??·'')`
}

Check failure on line 49 in react/components/CostCentersAutocomplete.tsx

View workflow job for this annotation

GitHub Actions / QE / Lint Node.js

Delete `··`

useEffect(() => {
const handler = setTimeout(() => {
Expand All @@ -67,12 +66,25 @@ const CostCenterAutocomplete = ({ onChange, organizationId }: Props) => {
search: debouncedSearchTerm,
})
} else if (debouncedSearchTerm === '') {
refetch({
...initialState,
id: organizationId,
search: '',
})
onChange({ value: null, label: '' })
}
}, [debouncedSearchTerm])

const handleChange = (selectedOption: { value: string | null; label: string } | null) => {

Check failure on line 78 in react/components/CostCentersAutocomplete.tsx

View workflow job for this annotation

GitHub Actions / QE / Lint Node.js

Replace `selectedOption:·{·value:·string·|·null;·label:·string·}·|·null` with `⏎····selectedOption:·{·value:·string·|·null;·label:·string·}·|·null⏎··`
onChange(selectedOption ?? { value: null, label: '' })
if (!selectedOption || !selectedOption.value) {
setCostCenterTextInput('')
refetch({
...initialState,
id: organizationId,
search: '',
})
}
onChange(selectedOption ?? { value: null, label: '' })

Check warning on line 87 in react/components/CostCentersAutocomplete.tsx

View workflow job for this annotation

GitHub Actions / QE / Lint Node.js

Expected blank line before this statement
}

return (
Expand All @@ -84,6 +96,7 @@ const CostCenterAutocomplete = ({ onChange, organizationId }: Props) => {
placeholder={formatMessage(messages.costCenter)}
multi={false}
valuesMaxHeight={200}
claerable={true}
/>
)
}
Expand Down

0 comments on commit 28f7dec

Please sign in to comment.