diff --git a/app/javascript/vue/global_search/filters.vue b/app/javascript/vue/global_search/filters.vue index 8c8458281..f4d1dd316 100644 --- a/app/javascript/vue/global_search/filters.vue +++ b/app/javascript/vue/global_search/filters.vue @@ -5,6 +5,7 @@
@@ -174,6 +178,9 @@ export default { if (this.searchQuery.length > 1) { this.fetchQuickSearchResults(); } + }, + filtersOpened() { + if (this.filtersOpened) this.$nextTick(() => { this.focusFilters() }); } }, data() { @@ -323,21 +330,32 @@ export default { focusHistoryItem(event) { if (this.focusedHistoryItem === null && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) { this.focusedHistoryItem = 0; - this.$refs.historyItems[this.focusedHistoryItem].focus(); + this.$refs.historyItems[this.focusedHistoryItem]?.focus(); } else if (event.key === 'ArrowDown') { event.preventDefault(); this.focusedHistoryItem += 1; if (this.focusedHistoryItem >= this.$refs.historyItems.length) { this.focusedHistoryItem = 0; } - this.$refs.historyItems[this.focusedHistoryItem].focus(); + this.$refs.historyItems[this.focusedHistoryItem]?.focus(); } else if (event.key === 'ArrowUp') { event.preventDefault(); this.focusedHistoryItem -= 1; if (this.focusedHistoryItem < 0) { this.focusedHistoryItem = this.$refs.historyItems.length - 1; } - this.$refs.historyItems[this.focusedHistoryItem].focus(); + this.$refs.historyItems[this.focusedHistoryItem]?.focus(); + } + }, + focusQuickSearchResults(e) { + this.$refs.experimentGroup?.focus(); + e.preventDefault(); + }, + focusFilters() { + const { filters } = this.$refs; + + if (filters) { + filters.$refs.groupButtons[0].focus(); } }, closeFlyout() {