Skip to content

Commit

Permalink
ON-33060 # Removed unnecessary callback deps, updated to clear value …
Browse files Browse the repository at this point in the history
…on empty label
  • Loading branch information
josh215 committed Jul 17, 2023
1 parent 83ed721 commit e687817
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/renderer/AutocompleteDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ function AutocompleteDropdown<T>({
(option) => option.label.toLowerCase() === lowerCase,
)
if (option) {
if (option.label.toLowerCase() !== label.toLowerCase()) {
console.log('Setting value after blurring away from autocomplete')
onSelectOption(option)
}
console.log('Setting value after blurring away from autocomplete')
onSelectOption(option)
return
}
if (value && !option) {
if (inputOption.value && !option) {
console.log(
'No option found, but there is a value so removing value',
)
Expand All @@ -112,14 +110,12 @@ function AutocompleteDropdown<T>({
}
},
[
label,
onChangeLabel,
onChangeValue,
onClose,
onSelectOption,
options,
setIsDirty,
value,
],
)

Expand All @@ -134,7 +130,6 @@ function AutocompleteDropdown<T>({
event.stopPropagation()

onSelectOption(option)
//handleBlur(option)
document.getElementById(id)?.blur()
},
[id, onSelectOption],
Expand Down Expand Up @@ -201,8 +196,11 @@ function AutocompleteDropdown<T>({
setCurrentFocusedOptionIndex(0)

onChangeLabel(newLabel)
if (!newLabel) {
onChangeValue(undefined)
}
},
[onChangeLabel, onOpen],
[onChangeLabel, onChangeValue, onOpen],
)

React.useEffect(() => {
Expand Down

0 comments on commit e687817

Please sign in to comment.