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 <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Oct 20, 2023
1 parent e733390 commit 0cf5ea8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/components/LeftSidebar/ConversationsListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
:item-size="CONVERSATION_ITEM_SIZE"
key-field="token">
<template #default="{ item }">
<Conversation :item="item" />
<Conversation :item="item" @click="click" />
</template>
<template #after>
<LoadingPlaceholder v-if="loading" type="conversations" />
Expand Down Expand Up @@ -65,6 +65,8 @@ export default {
},
},

emits: ['item-clicked'],

setup() {
return {
CONVERSATION_ITEM_SIZE,
Expand Down Expand Up @@ -151,6 +153,10 @@ export default {
this.scrollToItem(index)
}
},

click() {
this.$emit('item-clicked')
},
},
}
</script>
3 changes: 2 additions & 1 deletion src/components/LeftSidebar/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
:conversations="filteredConversationsList"
:loading="!initialisedConversations"
class="scroller h-100"
@scroll.native="debounceHandleScroll" />
@scroll.native="debounceHandleScroll"
@item-clicked="abortSearch" />
</li>
<NcButton v-if="!preventFindingUnread && lastUnreadMentionBelowViewportIndex !== null"
class="unread-mention-button"
Expand Down
17 changes: 12 additions & 5 deletions src/components/LeftSidebar/SearchBox/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,23 @@ 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
const list = document.querySelector('.left-sidebar__list')
if (list && 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 0cf5ea8

Please sign in to comment.