Add Ctrl+F handling to Channel search bar

This commit is contained in:
Jason Henriquez 2024-04-20 08:33:01 -05:00
parent fa1cd3632e
commit 7337fe1d1b
2 changed files with 10 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import autolinker from 'autolinker'
import { import {
setPublishedTimestampsInvidious, setPublishedTimestampsInvidious,
copyToClipboard, copyToClipboard,
ctrlFHandler,
extractNumberFromString, extractNumberFromString,
formatNumber, formatNumber,
showToast showToast
@ -434,6 +435,7 @@ export default defineComponent({
}, },
mounted: function () { mounted: function () {
this.isLoading = true this.isLoading = true
document.addEventListener('keydown', this.keyboardShortcutHandler)
if (this.$route.query.url) { if (this.$route.query.url) {
this.resolveChannelUrl(this.$route.query.url, this.$route.params.currentTab) this.resolveChannelUrl(this.$route.query.url, this.$route.params.currentTab)
@ -460,6 +462,9 @@ export default defineComponent({
}) })
} }
}, },
beforeDestroy() {
document.removeEventListener('keydown', this.keyboardShortcutHandler)
},
methods: { methods: {
resolveChannelUrl: async function (url, tab = undefined) { resolveChannelUrl: async function (url, tab = undefined) {
let id let id
@ -1950,6 +1955,10 @@ export default defineComponent({
}) })
}, },
keyboardShortcutHandler: function (event) {
ctrlFHandler(event, this.$refs.channelSearchBar)
},
...mapActions([ ...mapActions([
'showOutlines', 'showOutlines',
'updateSubscriptionDetails', 'updateSubscriptionDetails',

View File

@ -206,6 +206,7 @@
<ft-input <ft-input
v-if="showSearchBar" v-if="showSearchBar"
ref="channelSearchBar"
:placeholder="$t('Channel.Search Channel')" :placeholder="$t('Channel.Search Channel')"
:show-clear-text-button="true" :show-clear-text-button="true"
class="channelSearch" class="channelSearch"