Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus global search input on open #41652

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion core/src/views/GlobalSearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<!-- Global search form -->
<div ref="globalSearch" class="global-search-modal">
<h1>{{ t('core', 'Global search') }}</h1>
<NcInputField :value.sync="searchQuery"
<NcInputField ref="searchInput"
:value.sync="searchQuery"
type="text"
:label="t('core', 'Search apps, files, tags, messages') + '...'"
@update:value="debouncedFind" />
Expand Down Expand Up @@ -222,6 +223,15 @@ export default {
},
},
},
watch: {
isVisible(value) {
this.$nextTick(() => {
if (value) {
this.focusInput()
}
})
},
},
mounted() {
getProviders().then((providers) => {
this.providers = providers
Expand Down Expand Up @@ -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 = ''
Expand Down
4 changes: 2 additions & 2 deletions dist/core-global-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-global-search.js.map

Large diffs are not rendered by default.

Loading