mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 20:36:39 +08:00
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:
parent
3817e08b0f
commit
17e81018a2
|
@ -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"
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user