Skip to content

Commit b00b3b5

Browse files
committed
Implement fixes from code review
Fixes clear text button to appear and stay visible when the dropdown options are visible in an ft-input. Fixes updateVisibleDataList not using trim(), thus incorrectly causing filtering of search history when space bar was used.
1 parent d6f7542 commit b00b3b5

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ body[dir='rtl'] .ft-input-component.search.showClearTextButton:focus-within .inp
3131
padding-inline-start: 46px;
3232
}
3333

34-
.ft-input-component:focus-within .clearInputTextButton {
34+
.ft-input-component:focus-within .clearInputTextButton,
35+
.ft-input-component.showOptions .clearInputTextButton {
3536
opacity: 0.5;
3637
}
3738

38-
.clearTextButtonVisible .clearInputTextButton.visible,
39-
.ft-input-component:focus-within .clearInputTextButton.visible {
39+
.clearTextButtonVisible:not(.showOptions) .clearInputTextButton.visible,
40+
.ft-input-component:focus-within:not(.showOptions) .clearInputTextButton.visible {
4041
cursor: pointer;
4142
opacity: 1;
4243
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export default defineComponent({
9696
}
9797
},
9898
computed: {
99+
showOptions: function () {
100+
return (this.inputData !== '' || this.showDataWhenEmpty) && this.visibleDataList.length > 0 && this.searchState.showOptions
101+
},
102+
99103
barColor: function () {
100104
return this.$store.getters.getBarColor
101105
},
@@ -313,7 +317,7 @@ export default defineComponent({
313317
// Reset selected option before it's updated
314318
this.searchState.selectedOption = -1
315319
this.searchState.keyboardSelectedOptionIndex = -1
316-
if (this.inputData === '') {
320+
if (this.inputData.trim() === '') {
317321
this.visibleDataList = this.dataList
318322
return
319323
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
forceTextColor: forceTextColor,
88
showActionButton: showActionButton,
99
showClearTextButton: showClearTextButton,
10-
clearTextButtonVisible: inputDataPresent,
10+
clearTextButtonVisible: inputDataPresent || showOptions,
11+
showOptions: showOptions,
1112
disabled: disabled
1213
}"
1314
>
@@ -29,7 +30,7 @@
2930
:icon="['fas', 'times-circle']"
3031
class="clearInputTextButton"
3132
:class="{
32-
visible: inputDataPresent
33+
visible: inputDataPresent || showOptions
3334
}"
3435
tabindex="0"
3536
role="button"
@@ -68,7 +69,7 @@
6869
</span>
6970
<div class="options">
7071
<ul
71-
v-if="(inputData !== '' || showDataWhenEmpty) && visibleDataList.length > 0 && searchState.showOptions"
72+
v-if="showOptions"
7273
class="list"
7374
@mouseenter="searchState.isPointerInList = true"
7475
@mouseleave="searchState.isPointerInList = false"

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

Lines changed: 11 additions & 6 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.$router.currentRoute.fullPath) : this.searchSuggestionsDataList
130+
return this.lastSuggestionQuery === '' ? this.$store.getters.getLatestUniqueSearchHistoryEntries : this.searchSuggestionsDataList
131131
},
132132
},
133133
watch: {
@@ -180,11 +180,16 @@ export default defineComponent({
180180

181181
if (isFreeTubeInternalQuery) {
182182
const adjustedQuery = queryText.substring(3)
183-
openInternalPath({
184-
path: adjustedQuery,
185-
adjustedQuery,
186-
doCreateNewWindow
187-
})
183+
if (this.$router.currentRoute.fullPath !== adjustedQuery) {
184+
openInternalPath({
185+
path: adjustedQuery,
186+
adjustedQuery,
187+
doCreateNewWindow
188+
})
189+
}
190+
191+
// update in-use search query to the selected search history entry name
192+
this.lastSuggestionQuery = this.$store.getters.getSearchHistoryEntryWithRoute(adjustedQuery)?.name ?? ''
188193
return
189194
}
190195

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

0 commit comments

Comments
 (0)