Skip to content

Commit 617bf48

Browse files
authored
Fix Select/SelectMulti toggling from the caret icon (#1248)
1 parent f25da81 commit 617bf48

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636

3737
### Fixed
3838

39+
- `Select`/`SelectMulti` toggling the list from the caret
3940
- `Select` and `SelectMulti` keyboard navigation issues when filtering options
4041
- `SelectMulti` with `freeInput` tokenizing the input value when an option is clicked
4142
- `Tabs` now can be controlled

packages/components/src/Form/Inputs/Combobox/utils/useBlur.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ export function useBlur<
6868
}
6969
// we on want to close only if focus rests outside the select
7070
const popoverCurrent = listRef ? listRef.current : null
71-
if (e.relatedTarget !== inputElement && popoverCurrent) {
71+
if (popoverCurrent) {
7272
const focusInList =
7373
popoverCurrent && popoverCurrent.contains(e.relatedTarget as Node)
7474

7575
requestAnimationFrame(() => {
7676
if (focusInList && state !== ComboboxState.INTERACTING) {
7777
// focus landed inside the select, keep it open
7878
transition && transition(ComboboxActionType.INTERACT)
79-
} else if (!focusInList) {
79+
} else if (!focusInList && document.activeElement !== inputElement) {
8080
// focus landed outside the select, close it
8181
closeList()
8282
}

packages/components/src/Form/Inputs/InputChips/InputChips.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ export const InputChipsInternal = forwardRef(
141141
if (!isControlled) {
142142
setUncontrolledValue(val)
143143
}
144-
onInputChange && onInputChange(val)
144+
if (val !== inputValue) {
145+
onInputChange && onInputChange(val)
146+
}
145147
}
146148

147149
function updateValues(newInputValue?: string) {
@@ -150,12 +152,7 @@ export const InputChipsInternal = forwardRef(
150152
invalidValues,
151153
unusedValues,
152154
validValues,
153-
} = getUpdatedValues(
154-
// TypeScript can't tell that inputValue won't be undefined
155-
newInputValue || inputValue,
156-
values,
157-
validate
158-
)
155+
} = getUpdatedValues(newInputValue || inputValue, values, validate)
159156

160157
// Save valid values and keep invalid ones in the input
161158
const updatedInputValue = unusedValues.join(', ')

0 commit comments

Comments
 (0)