From ef73f18bff9780d01c4cae13087294b0481f68ed Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Tue, 21 Nov 2023 22:07:53 +0100 Subject: 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 Signed-off-by: nextcloud-command --- core/src/views/GlobalSearchModal.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'core/src') diff --git a/core/src/views/GlobalSearchModal.vue b/core/src/views/GlobalSearchModal.vue index b054b67633b..9058776780f 100644 --- a/core/src/views/GlobalSearchModal.vue +++ b/core/src/views/GlobalSearchModal.vue @@ -13,7 +13,8 @@

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

- @@ -222,6 +223,15 @@ export default { }, }, }, + watch: { + isVisible(value) { + this.$nextTick(() => { + if (value) { + this.focusInput() + } + }) + }, + }, mounted() { getProviders().then((providers) => { this.providers = providers @@ -503,6 +513,9 @@ export default { this.dateFilter.text = t('core', `Between ${this.dateFilter.startFrom.toLocaleDateString()} and ${this.dateFilter.endAt.toLocaleDateString()}`) this.updateDateFilter() }, + focusInput() { + this.$refs.searchInput.$el.children[0].children[0].focus() + }, closeModal() { this.$refs.globalSearchModal.close() this.searchQuery = '' -- cgit v1.2.3