Fix event propagation down the chain
This commit is contained in:
parent
f84e3c9f22
commit
f7def01442
2 changed files with 35 additions and 33 deletions
|
@ -114,7 +114,7 @@ export default ({ uuid }: { uuid: string }) => {
|
||||||
<CSSTransition timeout={250} in={menuVisible} unmountOnExit={true} classNames={'fade'}>
|
<CSSTransition timeout={250} in={menuVisible} unmountOnExit={true} classNames={'fade'}>
|
||||||
<div
|
<div
|
||||||
ref={menu}
|
ref={menu}
|
||||||
onClick={() => setMenuVisible(false)}
|
onClick={e => { e.stopPropagation(); setMenuVisible(false); }}
|
||||||
className={'absolute bg-white p-2 rounded border border-neutral-700 shadow-lg text-neutral-500 min-w-48'}
|
className={'absolute bg-white p-2 rounded border border-neutral-700 shadow-lg text-neutral-500 min-w-48'}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -15,45 +15,47 @@ export default ({ file }: { file: FileObject }) => {
|
||||||
const directory = ServerContext.useStoreState(state => state.files.directory);
|
const directory = ServerContext.useStoreState(state => state.files.directory);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<div
|
||||||
key={file.name}
|
key={file.name}
|
||||||
href={file.isFile ? undefined : `#${directory}/${file.name}`}
|
|
||||||
className={`
|
className={`
|
||||||
flex bg-neutral-700 text-neutral-300 rounded-sm mb-px text-sm
|
flex bg-neutral-700 rounded-sm mb-px text-sm
|
||||||
hover:text-neutral-100 cursor-pointer items-center no-underline hover:bg-neutral-600
|
hover:text-neutral-100 cursor-pointer items-center no-underline hover:bg-neutral-600
|
||||||
`}
|
`}
|
||||||
onClick={(e) => {
|
|
||||||
if (file.isFile) {
|
|
||||||
return e.preventDefault();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div className={'flex-none text-neutral-400 mr-4 text-lg pl-3'}>
|
<a
|
||||||
{file.isFile ?
|
href={file.isFile ? undefined : `#${directory}/${file.name}`}
|
||||||
<FontAwesomeIcon icon={file.isSymlink ? faFileImport : faFileAlt}/>
|
className={'flex flex-1 text-neutral-300 no-underline'}
|
||||||
:
|
onClick={e => {
|
||||||
<FontAwesomeIcon icon={faFolder}/>
|
file.isFile && e.preventDefault();
|
||||||
}
|
}}
|
||||||
</div>
|
|
||||||
<div className={'flex-1'}>
|
|
||||||
{file.name}
|
|
||||||
</div>
|
|
||||||
{file.isFile &&
|
|
||||||
<div className={'w-1/6 text-right mr-4'}>
|
|
||||||
{bytesToHuman(file.size)}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<div
|
|
||||||
className={'w-1/5 text-right mr-4'}
|
|
||||||
title={file.modifiedAt.toString()}
|
|
||||||
>
|
>
|
||||||
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
|
<div className={'flex-none text-neutral-400 mr-4 text-lg pl-3'}>
|
||||||
format(file.modifiedAt, 'MMM Do, YYYY h:mma')
|
{file.isFile ?
|
||||||
:
|
<FontAwesomeIcon icon={file.isSymlink ? faFileImport : faFileAlt}/>
|
||||||
distanceInWordsToNow(file.modifiedAt, { includeSeconds: true })
|
:
|
||||||
|
<FontAwesomeIcon icon={faFolder}/>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div className={'flex-1'}>
|
||||||
|
{file.name}
|
||||||
|
</div>
|
||||||
|
{file.isFile &&
|
||||||
|
<div className={'w-1/6 text-right mr-4'}>
|
||||||
|
{bytesToHuman(file.size)}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
<div
|
||||||
|
className={'w-1/5 text-right mr-4'}
|
||||||
|
title={file.modifiedAt.toString()}
|
||||||
|
>
|
||||||
|
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
|
||||||
|
format(file.modifiedAt, 'MMM Do, YYYY h:mma')
|
||||||
|
:
|
||||||
|
distanceInWordsToNow(file.modifiedAt, { includeSeconds: true })
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
<FileDropdownMenu uuid={file.uuid}/>
|
<FileDropdownMenu uuid={file.uuid}/>
|
||||||
</a>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue