Skip to content

Commit

Permalink
improve search box focus process
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <[email protected]>
  • Loading branch information
DorraJaouad committed Jul 17, 2023
1 parent 6714e9b commit 6699449
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/LeftSidebar/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
:value.sync="searchText"
class="conversations-search"
:class="{'conversations-search--expanded': isFocused}"
:is-focused="isFocused"
:is-searching="isSearching"
@focus="setIsFocused"
@blur="setIsFocused"
Expand Down Expand Up @@ -273,7 +274,7 @@ export default {
computed: {
conversationsList() {
let conversations = this.$store.getters.conversationsList
if (this.searchText !== '') {
if (this.searchText !== '' || this.isFocused) {
const lowerSearchText = this.searchText.toLowerCase()
conversations = conversations.filter(conversation =>
conversation.displayName.toLowerCase().includes(lowerSearchText)
Expand Down Expand Up @@ -384,7 +385,8 @@ export default {
return this.$el.querySelectorAll('li.acli_wrapper .acli')
},
setIsFocused(event) {
if (event.relatedTarget?.className.includes('input-field__clear-button') || this.searchText !== '') {
if ((event.type === 'click' && event.relatedTarget?.className.includes('input-field__clear-button'))
|| this.searchText !== '') {
return
}
this.isFocused = event.type === 'focus'
Expand Down
7 changes: 6 additions & 1 deletion src/components/LeftSidebar/SearchBox/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<NcTextField ref="searchConversations"
:value="value"
:label="placeholderText"
:show-trailing-button="isSearching"
:show-trailing-button="isFocused"
trailing-button-icon="close"
v-on="$listeners"
@update:value="updateValue"
Expand Down Expand Up @@ -66,6 +66,11 @@ export default {
/**
* If true, this component displays an 'x' button to abort the search
*/
isFocused: {
type: Boolean,
default: false,
},
isSearching: {
type: Boolean,
default: false,
Expand Down

0 comments on commit 6699449

Please sign in to comment.