|
|
@ -26,19 +26,18 @@ export default function DropdownSearchList ({ |
|
|
|
hideItemIf, |
|
|
|
hideItemIf, |
|
|
|
listContainerClassName, |
|
|
|
listContainerClassName, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
|
|
|
|
const t = useContext(I18nContext) |
|
|
|
|
|
|
|
const [isOpen, setIsOpen] = useState(false) |
|
|
|
|
|
|
|
const [selectedItem, setSelectedItem] = useState(startingItem) |
|
|
|
const close = () => { |
|
|
|
const close = () => { |
|
|
|
setIsOpen(false) |
|
|
|
setIsOpen(false) |
|
|
|
onClose && onClose() |
|
|
|
onClose && onClose() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const t = useContext(I18nContext) |
|
|
|
|
|
|
|
const [isOpen, setIsOpen] = useState(false) |
|
|
|
|
|
|
|
const [selectedItem, setSelectedItem] = useState(startingItem) |
|
|
|
|
|
|
|
const onClickItem = useCallback((item) => { |
|
|
|
const onClickItem = useCallback((item) => { |
|
|
|
onSelect && onSelect(item) |
|
|
|
onSelect && onSelect(item) |
|
|
|
setSelectedItem(item) |
|
|
|
setSelectedItem(item) |
|
|
|
close(); |
|
|
|
close() |
|
|
|
}, [onClose, onSelect]) |
|
|
|
}, [onSelect]) |
|
|
|
|
|
|
|
|
|
|
|
const onClickSelector = useCallback(() => { |
|
|
|
const onClickSelector = useCallback(() => { |
|
|
|
if (!isOpen) { |
|
|
|
if (!isOpen) { |
|
|
@ -65,7 +64,7 @@ export default function DropdownSearchList ({ |
|
|
|
<button |
|
|
|
<button |
|
|
|
className={classnames('dropdown-search-list', className)} |
|
|
|
className={classnames('dropdown-search-list', className)} |
|
|
|
onClick={onClickSelector} |
|
|
|
onClick={onClickSelector} |
|
|
|
onKeyUp={e => e.key === 'Escape' && close()} |
|
|
|
onKeyUp={(e) => e.key === 'Escape' && close()} |
|
|
|
> |
|
|
|
> |
|
|
|
{!isOpen && ( |
|
|
|
{!isOpen && ( |
|
|
|
<div |
|
|
|
<div |
|
|
|