MultiSelect: select values on blur
This commit is contained in:
parent
3313ea5885
commit
bf462380e6
1 changed files with 12 additions and 0 deletions
|
@ -100,6 +100,17 @@ function ComboMultipleDropdownList({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onBlur = (event) => {
|
||||||
|
if (
|
||||||
|
acceptNewValues &&
|
||||||
|
term &&
|
||||||
|
[...extraOptions, ...options].map(([label]) => label).includes(term)
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
return onSelect(term);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const saveSelection = (fn) => {
|
const saveSelection = (fn) => {
|
||||||
setSelections((selections) => {
|
setSelections((selections) => {
|
||||||
selections = fn(selections);
|
selections = fn(selections);
|
||||||
|
@ -162,6 +173,7 @@ function ComboMultipleDropdownList({
|
||||||
value={term}
|
value={term}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
|
onBlur={onBlur}
|
||||||
autocomplete={false}
|
autocomplete={false}
|
||||||
/>
|
/>
|
||||||
</ComboboxTokenLabel>
|
</ComboboxTokenLabel>
|
||||||
|
|
Loading…
Reference in a new issue