Skip to content

Commit c446274

Browse files
skjnldsvsusnux
authored andcommitted
fix(files): middle click & ctrl new tab
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 7880a5c commit c446274

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/files/src/components/FileEntryMixin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export default defineComponent({
356356

357357
// if ctrl+click / cmd+click (MacOS uses the meta key) or middle mouse button (button & 4), open in new tab
358358
// also if there is no default action use this as a fallback
359-
const metaKeyPressed = event.ctrlKey || event.metaKey || Boolean(event.button & 4)
359+
const metaKeyPressed = event.ctrlKey || event.metaKey || event.button === 1
360360
if (metaKeyPressed || !this.defaultFileAction) {
361361
// If no download permission, then we can not allow to download (direct link) the files
362362
if (isPublicShare() && !isDownloadable(this.source)) {
@@ -368,7 +368,9 @@ export default defineComponent({
368368
: generateUrl('/f/{fileId}', { fileId: this.fileid })
369369
event.preventDefault()
370370
event.stopPropagation()
371-
window.open(url, metaKeyPressed ? '_self' : undefined)
371+
372+
// Open the file in a new tab if the meta key or the middle mouse button is clicked
373+
window.open(url, metaKeyPressed ? '_blank' : '_self')
372374
return
373375
}
374376

0 commit comments

Comments
 (0)