This commit is contained in:
Benoit BAZARD 2024-06-12 21:28:54 +00:00 committed by GitHub
commit 2b12eeebcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -176,6 +176,7 @@ export default {
bus.$on('findPrev', this.listenFindPrev) bus.$on('findPrev', this.listenFindPrev)
document.addEventListener('click', this.docClick) document.addEventListener('click', this.docClick)
document.addEventListener('keyup', this.docKeyup) document.addEventListener('keyup', this.docKeyup)
bus.$on('search-blur', this.blurSearch)
}, },
beforeDestroy () { beforeDestroy () {
@ -185,6 +186,7 @@ export default {
bus.$off('findPrev', this.listenFindPrev) bus.$off('findPrev', this.listenFindPrev)
document.removeEventListener('click', this.docClick) document.removeEventListener('click', this.docClick)
document.removeEventListener('keyup', this.docKeyup) document.removeEventListener('keyup', this.docKeyup)
bus.$off('search-blur', this.blurSearch)
}, },
methods: { methods: {
@ -228,6 +230,10 @@ export default {
this.emptySearch(true) this.emptySearch(true)
}, },
blurSearch () {
this.emptySearch(true)
},
emptySearch (selectHighlight = false) { emptySearch (selectHighlight = false) {
this.showSearch = false this.showSearch = false
const searchValue = this.searchValue = '' const searchValue = this.searchValue = ''

View File

@ -7,6 +7,7 @@
type="text" v-model="keyword" type="text" v-model="keyword"
placeholder="Search in folder..." placeholder="Search in folder..."
@keyup="search" @keyup="search"
ref="search"
> >
<div class="controls"> <div class="controls">
<span <span
@ -125,14 +126,18 @@ export default {
}, },
watch: { watch: {
showSideBar: function (value, oldValue) { showSideBar: function (value, oldValue) {
if (value && !oldValue && this.rightColumn === 'search') { if (this.rightColumn === 'search') {
this.keyword = this.searchMatches.value if (value && !oldValue) {
this.handleFindInFolder(false)
} else {
bus.$emit('search-blur')
}
} }
} }
}, },
created () { created () {
this.$nextTick(() => { this.$nextTick(() => {
this.keyword = this.searchMatches.value this.handleFindInFolder()
bus.$on('findInFolder', this.handleFindInFolder) bus.$on('findInFolder', this.handleFindInFolder)
if (this.keyword.length > 0 && this.searcherRunning === false) { if (this.keyword.length > 0 && this.searcherRunning === false) {
this.searcherRunning = true this.searcherRunning = true
@ -316,8 +321,13 @@ export default {
openFolder () { openFolder () {
this.$store.dispatch('ASK_FOR_OPEN_PROJECT') this.$store.dispatch('ASK_FOR_OPEN_PROJECT')
}, },
handleFindInFolder () { handleFindInFolder (focus = true) {
this.keyword = this.searchMatches.value this.keyword = this.searchMatches.value
if (focus) {
this.$nextTick(() => {
this.$refs.search.focus()
})
}
} }
}, },
destroyed () { destroyed () {