Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #2294 Focus find-in-folder search box; unfocus with ESC #3421

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/renderer/components/search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export default {
bus.$on('findPrev', this.listenFindPrev)
document.addEventListener('click', this.docClick)
document.addEventListener('keyup', this.docKeyup)
bus.$on('search-blur', this.blurSearch)
},
beforeDestroy () {
Expand All @@ -185,6 +186,7 @@ export default {
bus.$off('findPrev', this.listenFindPrev)
document.removeEventListener('click', this.docClick)
document.removeEventListener('keyup', this.docKeyup)
bus.$off('search-blur', this.blurSearch)
},
methods: {
Expand Down Expand Up @@ -228,6 +230,10 @@ export default {
this.emptySearch(true)
},
blurSearch () {
this.emptySearch(true)
},
emptySearch (selectHighlight = false) {
this.showSearch = false
const searchValue = this.searchValue = ''
Expand Down
18 changes: 14 additions & 4 deletions src/renderer/components/sideBar/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
type="text" v-model="keyword"
placeholder="Search in folder..."
@keyup="search"
ref="search"
>
<div class="controls">
<span
Expand Down Expand Up @@ -125,14 +126,18 @@ export default {
},
watch: {
showSideBar: function (value, oldValue) {
if (value && !oldValue && this.rightColumn === 'search') {
this.keyword = this.searchMatches.value
if (this.rightColumn === 'search') {
if (value && !oldValue) {
this.handleFindInFolder(false)
} else {
bus.$emit('search-blur')
}
}
}
},
created () {
this.$nextTick(() => {
this.keyword = this.searchMatches.value
this.handleFindInFolder()
bus.$on('findInFolder', this.handleFindInFolder)
if (this.keyword.length > 0 && this.searcherRunning === false) {
this.searcherRunning = true
Expand Down Expand Up @@ -316,8 +321,13 @@ export default {
openFolder () {
this.$store.dispatch('ASK_FOR_OPEN_PROJECT')
},
handleFindInFolder () {
handleFindInFolder (focus = true) {
this.keyword = this.searchMatches.value
if (focus) {
this.$nextTick(() => {
this.$refs.search.focus()
})
}
}
},
destroyed () {
Expand Down