Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-09-14 17:46:24 +0300
committerJoas Schilling <coding@schilljs.com>2022-09-15 12:20:08 +0300
commit5267ea26241028cf193c0917f5ffd72adbba826f (patch)
tree4b0fdf921dd394469293927659bd4f4f31ac28f7 /core
parent7672152579447d1cc465a41d1b90004045236c29 (diff)
Add an OCP method to check the shortcut state and use it for global search and menu control
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core')
-rw-r--r--core/src/OCP/accessibility.js32
-rw-r--r--core/src/OCP/index.js2
-rw-r--r--core/src/components/HeaderMenu.vue5
-rw-r--r--core/src/views/UnifiedSearch.vue4
4 files changed, 43 insertions, 0 deletions
diff --git a/core/src/OCP/accessibility.js b/core/src/OCP/accessibility.js
new file mode 100644
index 00000000000..3839509228f
--- /dev/null
+++ b/core/src/OCP/accessibility.js
@@ -0,0 +1,32 @@
+/**
+ * @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com>
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+import { loadState } from '@nextcloud/initial-state'
+
+export default {
+ /**
+ * @return {boolean} Whether the user opted-out of shortcuts so that they should not be registered
+ */
+ disableKeyboardShortcuts() {
+ return loadState('theming', 'shortcutsDisabled', false)
+ },
+}
diff --git a/core/src/OCP/index.js b/core/src/OCP/index.js
index a6a5fe3e127..12766ad4977 100644
--- a/core/src/OCP/index.js
+++ b/core/src/OCP/index.js
@@ -28,12 +28,14 @@ import * as AppConfig from './appconfig'
import * as Comments from './comments'
import * as WhatsNew from './whatsnew'
+import Accessibility from './accessibility'
import Collaboration from './collaboration'
import Loader from './loader'
import Toast from './toast'
/** @namespace OCP */
export default {
+ Accessibility,
AppConfig,
Collaboration,
Comments,
diff --git a/core/src/components/HeaderMenu.vue b/core/src/components/HeaderMenu.vue
index 172ea7268d8..a2c19194b45 100644
--- a/core/src/components/HeaderMenu.vue
+++ b/core/src/components/HeaderMenu.vue
@@ -81,6 +81,7 @@ export default {
handler: this.closeMenu,
middleware: this.clickOutsideMiddleware,
},
+ shortcutsDisabled: OCP.Accessibility.disableKeyboardShortcuts(),
}
},
@@ -144,6 +145,10 @@ export default {
},
onKeyDown(event) {
+ if (this.shortcutsDisabled) {
+ return
+ }
+
// If opened and escape pressed, close
if (event.key === 'Escape' && this.opened) {
event.preventDefault()
diff --git a/core/src/views/UnifiedSearch.vue b/core/src/views/UnifiedSearch.vue
index 8611779754f..caceeb9006f 100644
--- a/core/src/views/UnifiedSearch.vue
+++ b/core/src/views/UnifiedSearch.vue
@@ -334,6 +334,10 @@ export default {
},
mounted() {
+ if (OCP.Accessibility.disableKeyboardShortcuts()) {
+ return
+ }
+
document.addEventListener('keydown', (event) => {
// if not already opened, allows us to trigger default browser on second keydown
if (event.ctrlKey && event.key === 'f' && !this.open) {