Avoid sending blur event when navigating the emoji picker
Also, listen to the `focusin` and `focusout` events, since they bubble, allowing us to listen on the chatbox itself.
This commit is contained in:
parent
8ab32f7b7d
commit
fdc8acf39f
@ -323,9 +323,8 @@ converse.plugins.add('converse-chatview', {
|
||||
'show_toolbar': _converse.show_toolbar,
|
||||
'unread_msgs': __('You have unread messages')
|
||||
}));
|
||||
const textarea = this.el.querySelector('.chat-textarea');
|
||||
textarea.addEventListener('focus', ev => this.emitFocused(ev));
|
||||
textarea.addEventListener('blur', ev => this.emitBlurred(ev));
|
||||
this.el.addEventListener('focusin', ev => this.emitFocused(ev));
|
||||
this.el.addEventListener('focusout', ev => this.emitBlurred(ev));
|
||||
this.renderToolbar();
|
||||
},
|
||||
|
||||
@ -1195,7 +1194,7 @@ converse.plugins.add('converse-chatview', {
|
||||
},
|
||||
|
||||
emitBlurred (ev) {
|
||||
if (this.el.contains(document.activeElement)) {
|
||||
if (this.el.contains(document.activeElement) || this.el.contains(ev.relatedTarget)) {
|
||||
// Something else in this chatbox is still focused
|
||||
return;
|
||||
}
|
||||
@ -1209,6 +1208,10 @@ converse.plugins.add('converse-chatview', {
|
||||
},
|
||||
|
||||
emitFocused (ev) {
|
||||
if (this.el.contains(ev.relatedTarget)) {
|
||||
// Something else in this chatbox was already focused
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Triggered when the focus has been moved to a particular chat.
|
||||
* @event _converse#chatBoxFocused
|
||||
|
@ -184,9 +184,6 @@ converse.plugins.add('converse-emoji-views', {
|
||||
|
||||
afterRender () {
|
||||
this.initIntersectionObserver();
|
||||
const textarea = this.el.querySelector('.emoji-search');
|
||||
textarea.addEventListener('focus', ev => this.chatview.emitFocused(ev));
|
||||
textarea.addEventListener('blur', ev => this.chatview.emitBlurred(ev));
|
||||
this.initArrowNavigation();
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user