Skip to content

Commit 20be3a7

Browse files
authored
Merge pull request #41706 from nextcloud/backport/41652/stable28
[stable28] Focus global search input on open
2 parents a8a114c + ef73f18 commit 20be3a7

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

core/src/views/GlobalSearchModal.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<!-- Global search form -->
1414
<div ref="globalSearch" class="global-search-modal">
1515
<h1>{{ t('core', 'Global search') }}</h1>
16-
<NcInputField :value.sync="searchQuery"
16+
<NcInputField ref="searchInput"
17+
:value.sync="searchQuery"
1718
type="text"
1819
:label="t('core', 'Search apps, files, tags, messages') + '...'"
1920
@update:value="debouncedFind" />
@@ -222,6 +223,15 @@ export default {
222223
},
223224
},
224225
},
226+
watch: {
227+
isVisible(value) {
228+
this.$nextTick(() => {
229+
if (value) {
230+
this.focusInput()
231+
}
232+
})
233+
},
234+
},
225235
mounted() {
226236
getProviders().then((providers) => {
227237
this.providers = providers
@@ -503,6 +513,9 @@ export default {
503513
this.dateFilter.text = t('core', `Between ${this.dateFilter.startFrom.toLocaleDateString()} and ${this.dateFilter.endAt.toLocaleDateString()}`)
504514
this.updateDateFilter()
505515
},
516+
focusInput() {
517+
this.$refs.searchInput.$el.children[0].children[0].focus()
518+
},
506519
closeModal() {
507520
this.$refs.globalSearchModal.close()
508521
this.searchQuery = ''

dist/core-global-search.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-global-search.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)