Skip to content

Commit f7def01

Browse files
committed
Fix event propagation down the chain
1 parent f84e3c9 commit f7def01

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

resources/scripts/components/server/files/FileDropdownMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default ({ uuid }: { uuid: string }) => {
114114
<CSSTransition timeout={250} in={menuVisible} unmountOnExit={true} classNames={'fade'}>
115115
<div
116116
ref={menu}
117-
onClick={() => setMenuVisible(false)}
117+
onClick={e => { e.stopPropagation(); setMenuVisible(false); }}
118118
className={'absolute bg-white p-2 rounded border border-neutral-700 shadow-lg text-neutral-500 min-w-48'}
119119
>
120120
<div

resources/scripts/components/server/files/FileObjectRow.tsx

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,47 @@ export default ({ file }: { file: FileObject }) => {
1515
const directory = ServerContext.useStoreState(state => state.files.directory);
1616

1717
return (
18-
<a
18+
<div
1919
key={file.name}
20-
href={file.isFile ? undefined : `#${directory}/${file.name}`}
2120
className={`
22-
flex bg-neutral-700 text-neutral-300 rounded-sm mb-px text-sm
21+
flex bg-neutral-700 rounded-sm mb-px text-sm
2322
hover:text-neutral-100 cursor-pointer items-center no-underline hover:bg-neutral-600
2423
`}
25-
onClick={(e) => {
26-
if (file.isFile) {
27-
return e.preventDefault();
28-
}
29-
}}
3024
>
31-
<div className={'flex-none text-neutral-400 mr-4 text-lg pl-3'}>
32-
{file.isFile ?
33-
<FontAwesomeIcon icon={file.isSymlink ? faFileImport : faFileAlt}/>
34-
:
35-
<FontAwesomeIcon icon={faFolder}/>
36-
}
37-
</div>
38-
<div className={'flex-1'}>
39-
{file.name}
40-
</div>
41-
{file.isFile &&
42-
<div className={'w-1/6 text-right mr-4'}>
43-
{bytesToHuman(file.size)}
44-
</div>
45-
}
46-
<div
47-
className={'w-1/5 text-right mr-4'}
48-
title={file.modifiedAt.toString()}
25+
<a
26+
href={file.isFile ? undefined : `#${directory}/${file.name}`}
27+
className={'flex flex-1 text-neutral-300 no-underline'}
28+
onClick={e => {
29+
file.isFile && e.preventDefault();
30+
}}
4931
>
50-
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
51-
format(file.modifiedAt, 'MMM Do, YYYY h:mma')
52-
:
53-
distanceInWordsToNow(file.modifiedAt, { includeSeconds: true })
32+
<div className={'flex-none text-neutral-400 mr-4 text-lg pl-3'}>
33+
{file.isFile ?
34+
<FontAwesomeIcon icon={file.isSymlink ? faFileImport : faFileAlt}/>
35+
:
36+
<FontAwesomeIcon icon={faFolder}/>
37+
}
38+
</div>
39+
<div className={'flex-1'}>
40+
{file.name}
41+
</div>
42+
{file.isFile &&
43+
<div className={'w-1/6 text-right mr-4'}>
44+
{bytesToHuman(file.size)}
45+
</div>
5446
}
55-
</div>
47+
<div
48+
className={'w-1/5 text-right mr-4'}
49+
title={file.modifiedAt.toString()}
50+
>
51+
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
52+
format(file.modifiedAt, 'MMM Do, YYYY h:mma')
53+
:
54+
distanceInWordsToNow(file.modifiedAt, { includeSeconds: true })
55+
}
56+
</div>
57+
</a>
5658
<FileDropdownMenu uuid={file.uuid}/>
57-
</a>
59+
</div>
5860
);
5961
};

0 commit comments

Comments
 (0)