client: improve clicking jump to file button

This commit is contained in:
Max Leiter 2022-04-01 17:26:01 -07:00
parent 06fad98ee1
commit f927fae9ed
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA

View file

@ -19,6 +19,9 @@ const FileDropdown = ({
}) => { }) => {
const [expanded, setExpanded] = useState(false) const [expanded, setExpanded] = useState(false)
const [items, setItems] = useState<Item[]>([]) const [items, setItems] = useState<Item[]>([])
const changeHandler = (next: boolean) => {
setExpanded(next)
}
const onOpen = useCallback(() => { const onOpen = useCallback(() => {
setExpanded(true) setExpanded(true)
@ -62,11 +65,15 @@ const FileDropdown = ({
// a list of files with an icon and a title // a list of files with an icon and a title
return ( return (
<>
<Button auto onClick={onOpen} className={styles.button} iconRight={<ChevronDown />}> <Button auto onClick={onOpen} className={styles.button} iconRight={<ChevronDown />}>
<Popover content={content} visible={expanded} hideArrow={true}>
Jump to {files.length} {files.length === 1 ? 'file' : 'files'} Jump to {files.length} {files.length === 1 ? 'file' : 'files'}
</Popover> </Button>
</Button > <Popover
onVisibleChange={changeHandler}
content={content} visible={expanded} hideArrow={true} onClick={onClose} />
</>
) )
} }