Skip to content

Commit 5359d84

Browse files
authored
Improve video playlist search UX (#4929)
* Enable playlist video search mode by default; add Ctrl+F binding * Fix subject-verb agreement on two search labels * Remove playlist video search bar when only one video is in the playlist * Add check for search video mode allowed that is requisite for keybinding * Remove unnecessary 'async function' in mounted * Fix styling issue
1 parent 981e8e4 commit 5359d84

File tree

7 files changed

+25
-51
lines changed

7 files changed

+25
-51
lines changed

src/renderer/components/playlist-info/playlist-info.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ export default defineComponent({
259259

260260
this.updateQueryDebounce = debounce(this.updateQuery, 500)
261261
},
262+
mounted: function () {
263+
document.addEventListener('keydown', this.keyboardShortcutHandler)
264+
},
265+
beforeDestroy: function () {
266+
document.removeEventListener('keydown', this.keyboardShortcutHandler)
267+
},
262268
methods: {
263269
toggleCopyVideosPrompt: function (force = false) {
264270
if (this.moreVideoDataAvailable && !this.isUserPlaylist && !force) {
@@ -403,24 +409,18 @@ export default defineComponent({
403409
this.query = query
404410
this.$emit('search-video-query-change', query)
405411
},
406-
enableVideoSearchMode() {
407-
this.searchVideoMode = true
408-
this.$emit('search-video-mode-on')
409412

410-
nextTick(() => {
411-
// Some elements only present after rendering update
412-
this.$refs.searchInput.focus()
413-
})
414-
},
415-
disableVideoSearchMode() {
416-
this.searchVideoMode = false
417-
this.updateQuery('')
418-
this.$emit('search-video-mode-off')
419-
420-
nextTick(() => {
421-
// Some elements only present after rendering update
422-
this.$refs.enableSearchModeButton?.focus()
423-
})
413+
keyboardShortcutHandler(event) {
414+
switch (event.key) {
415+
case 'F':
416+
case 'f':
417+
if (this.searchVideoModeAllowed && ((process.platform !== 'darwin' && event.ctrlKey) || (process.platform === 'darwin' && event.metaKey))) {
418+
nextTick(() => {
419+
// Some elements only present after rendering update
420+
this.$refs.searchInput.focus()
421+
})
422+
}
423+
}
424424
},
425425

426426
...mapActions([

src/renderer/components/playlist-info/playlist-info.scss

-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@
7575

7676
.searchInputsRow {
7777
margin-block-start: 8px;
78-
79-
display: grid;
80-
81-
/* 2 columns */
82-
grid-template-columns: 1fr auto;
83-
column-gap: 8px;
8478
}
8579

8680
@media only screen and (max-width: 1250px) {

src/renderer/components/playlist-info/playlist-info.vue

+1-16
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
<hr>
7777

7878
<div
79-
v-if="!searchVideoMode"
8079
class="channelShareWrapper"
8180
>
8281
<router-link
@@ -107,14 +106,6 @@
107106
</div>
108107

109108
<div class="playlistOptions">
110-
<ft-icon-button
111-
v-if="searchVideoModeAllowed && videoCount > 0 && !editMode"
112-
ref="enableSearchModeButton"
113-
:title="$t('User Playlists.SinglePlaylistView.Search for Videos')"
114-
:icon="['fas', 'search']"
115-
theme="secondary"
116-
@click="enableVideoSearchMode"
117-
/>
118109
<ft-icon-button
119110
v-if="editMode"
120111
:title="$t('User Playlists.Save Changes')"
@@ -198,7 +189,7 @@
198189
</div>
199190

200191
<div
201-
v-if="searchVideoModeAllowed && searchVideoMode"
192+
v-if="searchVideoModeAllowed"
202193
class="searchInputsRow"
203194
>
204195
<ft-input
@@ -211,12 +202,6 @@
211202
@input="(input) => updateQueryDebounce(input)"
212203
@clear="updateQueryDebounce('')"
213204
/>
214-
<ft-icon-button
215-
:title="$t('User Playlists.Cancel')"
216-
:icon="['fas', 'times']"
217-
theme="secondary"
218-
@click="disableVideoSearchMode"
219-
/>
220205
</div>
221206
</div>
222207
</template>

src/renderer/components/subscriptions-tab-ui/subscriptions-tab-ui.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default defineComponent({
8080
this.dataLimit = this.initialDataLimit
8181
}
8282
},
83-
mounted: async function () {
83+
mounted: function () {
8484
document.addEventListener('keydown', this.keyboardShortcutHandler)
8585
},
8686
beforeDestroy: function () {

src/renderer/views/Playlist/Playlist.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default defineComponent({
6060
getPlaylistInfoDebounce: function() {},
6161
playlistInEditMode: false,
6262

63-
playlistInVideoSearchMode: false,
6463
videoSearchQuery: '',
6564

6665
promptOpen: false,
@@ -112,9 +111,8 @@ export default defineComponent({
112111
return this.continuationData !== null
113112
}
114113
},
115-
116-
searchVideoModeAllowed() {
117-
return this.isUserPlaylistRequested
114+
playlistInVideoSearchMode() {
115+
return this.processedVideoSearchQuery !== ''
118116
},
119117
searchQueryTextRequested() {
120118
return this.$route.query.searchQueryText ?? ''
@@ -199,8 +197,7 @@ export default defineComponent({
199197
created: function () {
200198
this.getPlaylistInfoDebounce = debounce(this.getPlaylistInfo, 100)
201199

202-
if (this.searchVideoModeAllowed && this.searchQueryTextPresent) {
203-
this.playlistInVideoSearchMode = true
200+
if (this.isUserPlaylistRequested && this.searchQueryTextPresent) {
204201
this.videoSearchQuery = this.searchQueryTextRequested
205202
}
206203
},

src/renderer/views/Playlist/Playlist.vue

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
:view-count="viewCount"
2323
:info-source="infoSource"
2424
:more-video-data-available="moreVideoDataAvailable"
25-
:search-video-mode-allowed="searchVideoModeAllowed"
25+
:search-video-mode-allowed="isUserPlaylistRequested && videoCount > 1"
2626
:search-video-mode-enabled="playlistInVideoSearchMode"
2727
:search-query-text="searchQueryTextRequested"
2828
class="playlistInfo"
@@ -31,8 +31,6 @@
3131
}"
3232
@enter-edit-mode="playlistInEditMode = true"
3333
@exit-edit-mode="playlistInEditMode = false"
34-
@search-video-mode-on="playlistInVideoSearchMode = true"
35-
@search-video-mode-off="playlistInVideoSearchMode = false"
3634
@search-video-query-change="(v) => videoSearchQuery = v"
3735
@prompt-open="promptOpen = true"
3836
@prompt-close="promptOpen = false"

static/locales/en-US.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ User Playlists:
141141
Your saved videos are empty. Click on the save button on the corner of a video to have it listed here: Your saved videos are empty. Click on the save button on the corner of a video to have
142142
it listed here
143143
You have no playlists. Click on the create new playlist button to create a new one.: You have no playlists. Click on the create new playlist button to create a new one.
144-
Empty Search Message: There are no videos in this playlist that matches your search
144+
Empty Search Message: There are no videos in this playlist that match your search
145145
Search bar placeholder: Search for Playlists
146146
Playlists with Matching Videos: Playlists with Matching Videos
147147

@@ -235,7 +235,7 @@ History:
235235
History: History
236236
Watch History: Watch History
237237
Your history list is currently empty.: Your history list is currently empty.
238-
Empty Search Message: There are no videos in your history that matches your search
238+
Empty Search Message: There are no videos in your history that match your search
239239
Search bar placeholder: "Search in History"
240240
Settings:
241241
# On Settings Page

0 commit comments

Comments
 (0)