FIX: prevents long press to hijack reaction event (#22021)

Removing a reaction could start a long press at the same time and put the screen in a stuck state.

This commit ensures we give an opportunity to the reaction to capture the event first and not propagate further.
This commit is contained in:
Joffrey JAFFEUX 2023-06-09 00:39:34 +02:00 committed by GitHub
parent 3817e08b0f
commit 17e81018a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 28 deletions

View File

@ -1,8 +1,8 @@
{{#if (and @reaction this.emojiUrl)}}
<button
type="button"
{{on "touchstart" this.handleTouchStart}}
{{on "click" this.handleClick}}
{{on "click" this.handleClick bubbles=false}}
{{on "touchstart" this.handleClick bubbles=false}}
tabindex="0"
class={{concat-class
"chat-message-reaction"

View File

@ -45,15 +45,9 @@ export default class ChatMessageReaction extends Component {
return emojiUrlFor(this.args.reaction.emoji);
}
@action
handleTouchStart(event) {
this.handleClick(event);
}
@action
handleClick(event) {
event.stopPropagation();
event.preventDefault();
this.args.onReaction?.(
this.args.reaction.emoji,

View File

@ -35,7 +35,6 @@ export default class ChatOnLongPress extends Modifier {
element.addEventListener("touchstart", this.handleTouchStart, {
passive: true,
capture: true,
});
}
@ -43,15 +42,9 @@ export default class ChatOnLongPress extends Modifier {
onCancel() {
cancel(this.timeout);
this.element.removeEventListener("touchmove", this.onCancel, {
capture: true,
});
this.element.removeEventListener("touchend", this.onCancel, {
capture: true,
});
this.element.removeEventListener("touchcancel", this.onCancel, {
capture: true,
});
this.element.removeEventListener("touchmove", this.onCancel);
this.element.removeEventListener("touchend", this.onCancel);
this.element.removeEventListener("touchcancel", this.onCancel);
this.onLongPressCancel(this.element);
}
@ -65,15 +58,9 @@ export default class ChatOnLongPress extends Modifier {
this.onLongPressStart(this.element, event);
this.element.addEventListener("touchmove", this.onCancel, {
capture: true,
});
this.element.addEventListener("touchend", this.onCancel, {
capture: true,
});
this.element.addEventListener("touchcancel", this.onCancel, {
capture: true,
});
this.element.addEventListener("touchmove", this.onCancel);
this.element.addEventListener("touchend", this.onCancel);
this.element.addEventListener("touchcancel", this.onCancel);
this.timeout = discourseLater(() => {
if (this.isDestroying || this.isDestroyed) {
@ -82,7 +69,6 @@ export default class ChatOnLongPress extends Modifier {
this.element.addEventListener("touchend", cancelEvent, {
once: true,
capture: true,
});
this.onLongPressEnd(this.element, event);