From 097219ba06859924015ac22ed08ea1a6f6ffdd1b Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Tue, 21 Nov 2023 22:07:53 +0100 Subject: [PATCH] Focus global search input on open For better accesibility, the search input in the global search modal should be focused when the search modal is opened. Resolves: https://github.com/nextcloud/server/issues/41651 Signed-off-by: fenn-cs --- core/src/views/GlobalSearchModal.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/views/GlobalSearchModal.vue b/core/src/views/GlobalSearchModal.vue index d7e911c35fac5..f456a2e6ee7fa 100644 --- a/core/src/views/GlobalSearchModal.vue +++ b/core/src/views/GlobalSearchModal.vue @@ -13,7 +13,8 @@

{{ t('core', 'Global search') }}

- @@ -212,6 +213,7 @@ export default { }, }, mounted() { + this.initSearch() getProviders().then((providers) => { this.providers = providers console.debug('Search providers', this.providers) @@ -489,6 +491,15 @@ export default { this.dateFilter.text = t('core', `Between ${this.dateFilter.startFrom.toLocaleDateString()} and ${this.dateFilter.endAt.toLocaleDateString()}`) this.updateDateFilter() }, + // For initialization operations that should happen when component is mounted + initSearch() { + this.focusInput() + }, + focusInput() { + this.$nextTick(() => { + this.$refs.search.$el.children[0].children[0].focus() + }) + }, closeModal() { this.searchQuery = '' },