From 42269c4d360d9fb8e79d002530a53b0450a767e5 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Wed, 18 Dec 2024 11:13:08 +0100 Subject: [PATCH] fix: hotkey is shift+u Signed-off-by: skjnldsv --- cypress/components/UploadPicker/hotkeys.cy.ts | 5 ++--- lib/components/UploadPicker.vue | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cypress/components/UploadPicker/hotkeys.cy.ts b/cypress/components/UploadPicker/hotkeys.cy.ts index 8e84697f..e32a7883 100644 --- a/cypress/components/UploadPicker/hotkeys.cy.ts +++ b/cypress/components/UploadPicker/hotkeys.cy.ts @@ -8,7 +8,6 @@ import { Folder, Permission, addNewFileMenuEntry, type Entry } from '@nextcloud/files' import { generateRemoteUrl } from '@nextcloud/router' import { UploadPicker } from '../../../lib/index.ts' -import type { ComponentPublicInstance } from 'vue' describe('UploadPicker: hotkeys testing', () => { const propsData = { @@ -31,7 +30,7 @@ describe('UploadPicker: hotkeys testing', () => { } as Entry) }) - it('opens the upload menu when pressing u', () => { + it('opens the upload menu when pressing shift+u', () => { cy.mount(UploadPicker, { propsData }) // Check and init aliases @@ -40,7 +39,7 @@ describe('UploadPicker: hotkeys testing', () => { cy.get('[role="menu"]').should('not.exist') - cy.get('body').type('u') + cy.get('body').type('{shift}u') cy.get('[role="menu"]').should('be.visible') }) diff --git a/lib/components/UploadPicker.vue b/lib/components/UploadPicker.vue index 21cd679f..bc8621a0 100644 --- a/lib/components/UploadPicker.vue +++ b/lib/components/UploadPicker.vue @@ -366,7 +366,13 @@ export default defineComponent({ this.uploadManager.addNotifier(this.onUploadCompletion) // Register hotkeys - useHotKey(['u', 'Escape'], this.onKeyDown, { + useHotKey('u', this.onKeyDown, { + stop: true, + prevent: true, + shift: true, + }) + + useHotKey('Escape', this.onKeyDown, { stop: true, prevent: true, }) @@ -483,6 +489,7 @@ export default defineComponent({ }, onKeyDown(event: KeyboardEvent) { + // Shift + u opens the menu if (event.key === 'u') { // If we have a menu, open it if (this.haveMenu) {