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

[Stable27] fix(LeftSidebar): Disable blur event in order to click on a conversation #10781

Merged
merged 2 commits into from Oct 26, 2023
Merged
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
Expand Up @@ -21,6 +21,7 @@

<template>
<NcListItem ref="listItem"
:key="item.token"
:title="item.displayName"
class="conversation-item"
:class="{'unread-mention-conversation': item.unreadMention}"
Expand Down
4 changes: 4 additions & 0 deletions src/components/LeftSidebar/LeftSidebar.vue
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
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