1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
This commit is contained in:
David Walsh 2020-10-23 15:01:50 -05:00
parent 15aba70e74
commit 14fff6dcf2
2 changed files with 7 additions and 8 deletions

View File

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

View File

@ -54,7 +54,7 @@ export default function ItemList ({
'searchable-item-list__item--disabled': disabled,
})}
onClick={onClick}
onKeyUp={e => e.key === "Enter" && onClick()}
onKeyUp={(e) => e.key === 'Enter' && onClick()}
key={`searchable-item-list-item-${i}`}
>
{(iconUrl || primaryLabel) && (<UrlIcon url={iconUrl} name={primaryLabel} />)}