MultiSelect: enable adding multiple emails with , or space

This commit is contained in:
Paul Chavard 2021-05-20 11:51:39 +02:00
parent 868a8621e1
commit 868ec214ce
3 changed files with 13 additions and 1 deletions

View file

@ -19,6 +19,7 @@ import '@reach/combobox/styles.css';
import { matchSorter } from 'match-sorter';
import { fire } from '@utils';
import { XIcon } from '@heroicons/react/outline';
import isHotkey from 'is-hotkey';
const Context = createContext();
@ -83,7 +84,12 @@ function ComboMultipleDropdownList({
};
const onKeyDown = (event) => {
if (event.key === 'Enter') {
if (
isHotkey('enter', event) ||
isHotkey(' ', event) ||
isHotkey(',', event) ||
isHotkey(';', event)
) {
if (
term &&
[...extraOptions, ...options].map(([label]) => label).includes(term)