Skip to content

Commit

Permalink
fix(LeftSidebar): disable the blur event of the search box when click…
Browse files Browse the repository at this point in the history
…ing on a conversation.

Signed-off-by: DorraJaouad <[email protected]>
  • Loading branch information
DorraJaouad committed Oct 26, 2023
1 parent 16e507a commit 3a4d174
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/components/LeftSidebar/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<SearchBox ref="searchBox"
:value.sync="searchText"
:is-focused.sync="isFocused"
:list="container"
@input="debounceFetchSearchResults"
@abort-search="abortSearch" />
</div>
Expand Down Expand Up @@ -312,6 +313,7 @@ export default {
setup() {
const leftSidebar = ref(null)
const searchBox = ref(null)
const container = ref(null)
const { initializeNavigation, resetNavigation } = useArrowNavigation(leftSidebar, searchBox, '.list-item')
Expand All @@ -320,6 +322,7 @@ export default {
resetNavigation,
leftSidebar,
searchBox,
container,
}
},
Expand Down Expand Up @@ -791,6 +794,7 @@ export default {
}
}
if (to.name === 'conversation') {
this.abortSearch()
this.$store.dispatch('joinConversation', { token: to.params.token })
this.scrollToConversation(to.params.token)
}
Expand Down
23 changes: 18 additions & 5 deletions src/components/LeftSidebar/SearchBox/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export default {
type: Boolean,
required: true,
},
/**
* Conversations list reference for handling click trigger
*/
list: {
type: HTMLElement,
default: null,
},
},
expose: ['focus'],
Expand Down Expand Up @@ -136,16 +143,22 @@ export default {
},
handleBlur(event) {
// Blur triggered by clicking on the trailing button
if (event.relatedTarget?.classList.contains('input-field__clear-button')) {
event.preventDefault()
this.getTrailingButton()?.addEventListener('blur', (trailingEvent) => {
this.handleBlur(trailingEvent)
})
} else {
this.$emit('blur', event)
if (this.value === '') {
this.$emit('update:is-focused', false)
}
return
}
// Blur triggered by clicking on a conversation item
if (this.list?.contains(event.relatedTarget)) {
return
}
// Blur in other cases
this.$emit('blur', event)
if (this.value === '') {
this.$emit('update:is-focused', false)
}
},
Expand Down

0 comments on commit 3a4d174

Please sign in to comment.