Skip to content

Commit

Permalink
Implement fixes from code review
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kommunarr committed Dec 20, 2024
1 parent d6f7542 commit 10e17ef
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
13 changes: 6 additions & 7 deletions src/renderer/components/ft-input/ft-input.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ body[dir='rtl'] .ft-input-component.search.showClearTextButton:focus-within .inp
padding-inline-start: 46px;
}

.ft-input-component:focus-within .clearInputTextButton {
.ft-input-component:focus-within .clearInputTextButton,
.ft-input-component.showOptions .clearInputTextButton {
opacity: 0.5;
}

.clearTextButtonVisible .clearInputTextButton.visible,
.ft-input-component:focus-within .clearInputTextButton.visible {

.ft-input-component.inputDataPresent .clearInputTextButton.visible,
.clearTextButtonVisible:not(.showOptions) .clearInputTextButton.visible,
.ft-input-component:focus-within:not(.showOptions) .clearInputTextButton.visible {
cursor: pointer;
opacity: 1;
}
Expand Down Expand Up @@ -209,10 +212,6 @@ body[dir='rtl'] .ft-input-component.search.showClearTextButton:focus-within .inp
white-space: nowrap;
}

.bookmarkStarIcon {
color: var(--favorite-icon-color);
}

.searchResultIcon {
opacity: 0.6;
padding-inline-end: 10px;
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/components/ft-input/ft-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export default defineComponent({
}
},
computed: {
showOptions: function () {
return (this.inputData !== '' || this.showDataWhenEmpty) && this.visibleDataList.length > 0 && this.searchState.showOptions
},

barColor: function () {
return this.$store.getters.getBarColor
},
Expand Down Expand Up @@ -313,7 +317,7 @@ export default defineComponent({
// Reset selected option before it's updated
this.searchState.selectedOption = -1
this.searchState.keyboardSelectedOptionIndex = -1
if (this.inputData === '') {
if (this.inputData.trim() === '') {
this.visibleDataList = this.dataList
return
}
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/components/ft-input/ft-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
forceTextColor: forceTextColor,
showActionButton: showActionButton,
showClearTextButton: showClearTextButton,
clearTextButtonVisible: inputDataPresent,
clearTextButtonVisible: inputDataPresent || showOptions,
showOptions: showOptions,
disabled: disabled
}"
>
Expand All @@ -29,7 +30,7 @@
:icon="['fas', 'times-circle']"
class="clearInputTextButton"
:class="{
visible: inputDataPresent
visible: inputDataPresent || showOptions
}"
tabindex="0"
role="button"
Expand Down Expand Up @@ -68,7 +69,7 @@
</span>
<div class="options">
<ul
v-if="(inputData !== '' || showDataWhenEmpty) && visibleDataList.length > 0 && searchState.showOptions"
v-if="showOptions"
class="list"
@mouseenter="searchState.isPointerInList = true"
@mouseleave="searchState.isPointerInList = false"
Expand Down
17 changes: 11 additions & 6 deletions src/renderer/components/top-nav/top-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default defineComponent({
if (!this.enableSearchSuggestions) {
return
}
return this.lastSuggestionQuery === '' ? this.$store.getters.getLatestUniqueSearchHistoryEntries(this.$router.currentRoute.fullPath) : this.searchSuggestionsDataList
return this.lastSuggestionQuery === '' ? this.$store.getters.getLatestUniqueSearchHistoryEntries : this.searchSuggestionsDataList
},
},
watch: {
Expand Down Expand Up @@ -180,11 +180,16 @@ export default defineComponent({

if (isFreeTubeInternalQuery) {
const adjustedQuery = queryText.substring(3)
openInternalPath({
path: adjustedQuery,
adjustedQuery,
doCreateNewWindow
})
if (this.$router.currentRoute.fullPath !== adjustedQuery) {
openInternalPath({
path: adjustedQuery,
adjustedQuery,
doCreateNewWindow
})
}

// update in-use search query to the selected search history entry name
this.lastSuggestionQuery = this.$store.getters.getSearchHistoryEntryWithRoute(adjustedQuery)?.name ?? ''
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/store/modules/search-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const getters = {
return state.searchHistoryEntries
},

getLatestUniqueSearchHistoryEntries: (state) => (routeToExclude) => {
getLatestUniqueSearchHistoryEntries: (state) => {
const nameSet = new Set()
return state.searchHistoryEntries.filter((entry) => {
if (nameSet.has(entry.name) || routeToExclude === entry.route) {
if (nameSet.has(entry.name)) {
return false
}

Expand Down

0 comments on commit 10e17ef

Please sign in to comment.