FIX: correctly nullifies active message (#21739)

Very fast or specific mouse moves could allow to leave a message actions menu without reseting the active message. This commit should ensure we correctly catch this event.

No test as it's hard and not reliable to reproduce these in a test.
This commit is contained in:
Joffrey JAFFEUX 2023-05-25 09:28:46 +02:00 committed by GitHub
parent a048aeef6a
commit 082921c4c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -2,6 +2,7 @@
<div
{{did-insert this.setup}}
{{did-update this.setup this.chat.activeMessage.model.id}}
{{on "mouseleave" this.onMouseleave}}
{{will-destroy this.teardown}}
class={{concat-class
"chat-message-actions-container"

View File

@ -44,6 +44,21 @@ export default class ChatMessageActionsDesktop extends Component {
return this.size === FULL;
}
@action
onMouseleave(event) {
// if the mouse is leaving the actions menu for the actual menu, don't close it
// this will avoid the menu rerendering
if (
(event.toElement || event.relatedTarget)?.closest(
".chat-message-container"
)
) {
return;
}
this.chat.activeMessage = null;
}
@action
setup(element) {
this.popper?.destroy();