A platform for community discussion. Free, open, simple.
UX: adds small delay before making message active (#22221)
Joffrey JAFFEUX720c0c6e4d01
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message.hbsindex c074f8e528d..105ec95af60 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.hbs@@ -35,8 +35,8 @@{{on "mouseleave" this.onMouseLeave passive=true}}{{on "mousemove" this.onMouseMove passive=true}}{{chat/on-long-press- this.handleLongPressStart- this.handleLongPressEnd+ this.onLongPressStart+ this.onLongPressEndthis.onLongPressCancel}}{{chat/track-messagediff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.js b/plugins/chat/assets/javascripts/discourse/components/chat-message.jsindex 1fa0d20550d..0eb7b17e2f2 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.js@@ -132,6 +132,7 @@ export default class ChatMessage extends Component {willDestroyMessage() {cancel(this._invitationSentTimer);cancel(this._disableMessageActionsHandler);+ cancel(this._makeMessageActiveHandler);this.#teardownMentionedUsers();}@@ -272,16 +273,22 @@ export default class ChatMessage extends Component {}@action- handleLongPressStart() {+ onLongPressStart() {if (!this.args.message.expanded) {return;}- this.isActive = true;+ // prevents message to show as active when starting scroll+ // at this moment scroll has no momentum and the row can+ // capture the touch event instead of a scroll+ this._makeMessageActiveHandler = discourseLater(() => {+ this.isActive = true;+ }, 50);}@actiononLongPressCancel() {+ cancel(this._makeMessageActiveHandler);this.isActive = false;// this a tricky bit of code which is needed to prevent the long press@@ -297,7 +304,8 @@ export default class ChatMessage extends Component {}@action- handleLongPressEnd() {+ onLongPressEnd() {+ cancel(this._makeMessageActiveHandler);this.isActive = false;if (isZoomed()) {