From 7dafd275aca467ebd729cbe8723c2ee91fda983e Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 16 Jun 2023 11:36:43 +0200 Subject: [PATCH] FIX: various mobile chat improvements (#22132) - FIX: improves reactions and thread indicator touch event on mobile These "buttons" are located inside a scroll list which makes them very specific. The general idea is to ensure these events are passive and are not bubbling to the parent. - DEV: moves state on top level message node - FIX: ensures popover arrow has the correct border - FIX: makes a message expanded by default - FIX applies the same ios scroll fix on thread and channel - UI: better active/hover state for thread indicator - UI: attempts to follow more closely our BEM naming scheme - FIX: reduces bottom padding on message with thread indicator and user info hidden - UI: add padding for first message in thread - FIX: prevents actions backdrop to open thread - UI: makes thread indicator resizable --- .../discourse/app/helpers/format-date.js | 1 + .../discourse/app/lib/formatter.js | 6 + .../tests/unit/lib/formatter-test.js | 3 + .../stylesheets/common/base/d-popover.scss | 10 +- .../chat-message-actions-mobile.hbs | 2 +- .../components/chat-message-actions-mobile.js | 5 +- .../components/chat-message-reaction.hbs | 7 +- .../components/chat-message-reaction.js | 121 ++++++++++-- .../chat-message-thread-indicator.hbs | 27 +-- .../chat-message-thread-indicator.js | 81 +++++++- .../discourse/components/chat-message.hbs | 58 +++--- .../discourse/components/chat-message.js | 70 ++++--- .../discourse/components/chat-thread.js | 31 ++- .../discourse/models/chat-message.js | 18 +- .../discourse/modifiers/chat/on-long-press.js | 15 +- .../stylesheets/common/base-common.scss | 4 +- .../common/chat-message-thread-indicator.scss | 48 ++++- .../stylesheets/common/chat-message.scss | 184 ++++++++---------- .../stylesheets/desktop/base-desktop.scss | 28 +-- .../chat-message-thread-indicator.scss | 2 - .../stylesheets/mobile/base-mobile.scss | 6 +- .../stylesheets/mobile/chat-message.scss | 2 +- .../stylesheets/mobile/chat-thread.scss | 5 +- .../spec/system/chat_message/channel_spec.rb | 2 +- .../spec/system/chat_message/thread_spec.rb | 2 +- .../chat/spec/system/deleted_message_spec.rb | 2 +- .../system/page_objects/chat/chat_channel.rb | 4 +- .../page_objects/chat/components/message.rb | 10 +- .../components/chat-message-test.js | 2 - 29 files changed, 492 insertions(+), 264 deletions(-) diff --git a/app/assets/javascripts/discourse/app/helpers/format-date.js b/app/assets/javascripts/discourse/app/helpers/format-date.js index 5cc5f6ca017..0f41327a016 100644 --- a/app/assets/javascripts/discourse/app/helpers/format-date.js +++ b/app/assets/javascripts/discourse/app/helpers/format-date.js @@ -28,6 +28,7 @@ registerUnbound("format-date", function (val, params) { format, title, leaveAgo, + prefix: params.prefix, }) ); } diff --git a/app/assets/javascripts/discourse/app/lib/formatter.js b/app/assets/javascripts/discourse/app/lib/formatter.js index 66cd9991959..6493ba18e8e 100644 --- a/app/assets/javascripts/discourse/app/lib/formatter.js +++ b/app/assets/javascripts/discourse/app/lib/formatter.js @@ -102,6 +102,11 @@ export function autoUpdatingRelativeAge(date, options) { append += "' title='" + longDate(date); } + let prefix = ""; + if (options.prefix) { + prefix = options.prefix + " "; + } + return ( "" + + prefix + relAge + "" ); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js b/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js index 1b632c30f04..cda9778eb08 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js @@ -260,6 +260,9 @@ module("Unit | Utility | formatter", function (hooks) { assert.strictEqual(elem.dataset.time, d.getTime().toString()); assert.strictEqual(elem.title, ""); assert.strictEqual(elem.innerHTML, "1 day"); + + elem = domFromString(autoUpdatingRelativeAge(d, { prefix: "test" }))[0]; + assert.strictEqual(elem.innerHTML, "test 1d"); }); test("updateRelativeAge", function (assert) { diff --git a/app/assets/stylesheets/common/base/d-popover.scss b/app/assets/stylesheets/common/base/d-popover.scss index ba497cdb052..eaab5b6d627 100644 --- a/app/assets/stylesheets/common/base/d-popover.scss +++ b/app/assets/stylesheets/common/base/d-popover.scss @@ -15,8 +15,14 @@ $d-popover-border: var(--primary-low); top: -10px; } -.tippy-svg-arrow > svg { - color: $d-popover-background; +#tippy-rounded-arrow { + .svg-content { + fill: $d-popover-background; + } + + .svg-arrow { + fill: $d-popover-border; + } } [data-tooltip] > *, diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs index dcb3810ba22..a5d3326217a 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.hbs @@ -9,7 +9,7 @@
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.js b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.js index db7b5c72bc9..43c2373c121 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-mobile.js @@ -15,8 +15,6 @@ export default class ChatMessageActionsMobile extends Component { @tracked hasExpandedReply = false; @tracked showFadeIn = false; - messageActions = null; - get message() { return this.chat.activeMessage.model; } @@ -49,7 +47,8 @@ export default class ChatMessageActionsMobile extends Component { } @action - collapseMenu() { + collapseMenu(event) { + event.preventDefault(); this.#onCloseMenu(); } diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbs index fcfdbf47cec..44aa89c5dda 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbs @@ -1,18 +1,17 @@ {{#if (and @reaction this.emojiUrl)}}