Skip to content

Commit c6df924

Browse files
committed
Exclude current search route from history suggestions and populate input with matching query
1 parent 679496f commit c6df924

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/renderer/components/ft-input/ft-input.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export default defineComponent({
172172
this.$emit('input', val)
173173
},
174174

175-
handleClearTextClick: function ({ programmaticallyTriggered = false }) {
175+
handleClearTextClick: function () {
176176
// No action if no input text
177177
if (!this.inputDataPresent) { return }
178178

@@ -183,9 +183,7 @@ export default defineComponent({
183183
this.$refs.input.value = ''
184184

185185
// Focus on input element after text is clear for better UX
186-
if (!programmaticallyTriggered) {
187-
this.$refs.input.focus()
188-
}
186+
this.$refs.input.focus()
189187

190188
this.$emit('clear')
191189
},
@@ -244,10 +242,12 @@ export default defineComponent({
244242
this.searchState.showOptions = false
245243
if (this.visibleDataList[index].route) {
246244
this.inputData = `ft:${this.visibleDataList[index].route}`
245+
this.$emit('input', this.inputData)
246+
this.inputData = this.$refs.input.value = this.visibleDataList[index].name
247247
} else {
248248
this.inputData = this.visibleDataList[index]
249+
this.$emit('input', this.inputData)
249250
}
250-
this.$emit('input', this.inputData)
251251
this.handleClick()
252252
},
253253

src/renderer/components/top-nav/top-nav.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default defineComponent({
127127
if (!this.enableSearchSuggestions) {
128128
return
129129
}
130-
return this.lastSuggestionQuery === '' ? this.$store.getters.getLatestUniqueSearchHistoryEntries : this.searchSuggestionsDataList
130+
return this.lastSuggestionQuery === '' ? this.$store.getters.getLatestUniqueSearchHistoryEntries(this.$router.currentRoute.fullPath) : this.searchSuggestionsDataList
131131
},
132132
},
133133
watch: {
@@ -177,7 +177,6 @@ export default defineComponent({
177177
clearLocalSearchSuggestionsSession()
178178

179179
if (queryText.startsWith('ft:')) {
180-
this.$refs.searchInput.handleClearTextClick({ programmaticallyTriggered: true })
181180
const adjustedQuery = queryText.substring(3)
182181
openInternalPath({
183182
path: adjustedQuery,

src/renderer/store/modules/search-history.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const getters = {
1212
return state.searchHistoryEntries
1313
},
1414

15-
getLatestUniqueSearchHistoryEntries: (state) => {
15+
getLatestUniqueSearchHistoryEntries: (state) => (routeToExclude) => {
1616
const nameSet = new Set()
1717
return state.searchHistoryEntries.filter((entry) => {
18-
if (nameSet.has(entry.name)) {
18+
if (nameSet.has(entry.name) || routeToExclude === entry.route) {
1919
return false
2020
}
2121

0 commit comments

Comments
 (0)