A platform for community discussion. Free, open, simple.
FIX: various mobile optimizations (#22043)
Joffrey JAFFEUX89d7b1861d16
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel.hbsindex 529b9e67459..091a65368ec 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.hbs@@ -34,7 +34,7 @@><divclass="chat-messages-container"- {{chat/on-resize this.didResizePane (hash delay=25 immediate=true)}}+ {{chat/on-resize this.didResizePane (hash delay=100 immediate=true)}}>{{#if this.loadedOnce}}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.js b/plugins/chat/assets/javascripts/discourse/components/chat-channel.jsindex bc0c1ee2742..a1563581d72 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.js@@ -966,31 +966,22 @@ export default class ChatLivePane extends Component {// we now use this hack to disable it@bindforceRendering(callback) {- schedule("afterRender", () => {- if (this._selfDeleted) {- return;- }-- if (!this.scrollable) {- return;- }-- if (this.capabilities.isIOS) {- this.scrollable.style.overflow = "hidden";- }+ if (this.capabilities.isIOS) {+ this.scrollable.style.overflow = "hidden";+ }- callback?.();+ callback?.();- if (this.capabilities.isIOS) {- discourseLater(() => {- if (!this.scrollable) {+ if (this.capabilities.isIOS) {+ next(() => {+ schedule("afterRender", () => {+ if (this._selfDeleted || !this.scrollable) {return;}-this.scrollable.style.overflow = "auto";- }, 50);- }- });+ });+ });+ }}_computeDatesSeparators() {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.hbsindex d61d03ef8fe..dcb3810ba22 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 @@<divrole="button"class="collapse-area"- {{on "touchstart" this.collapseMenu}}+ {{on "touchstart" this.collapseMenu passive=true bubbles=false}}></div>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.jsindex 5f5db9660ee..db7b5c72bc9 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@@ -49,8 +49,7 @@ export default class ChatMessageActionsMobile extends Component {}@action- collapseMenu(event) {- event.preventDefault();+ collapseMenu() {this.#onCloseMenu();}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message.hbsindex 70a16b5faaa..79eae17fb63 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.hbs@@ -26,6 +26,7 @@(if (eq @message.user.id this.currentUser.id) "is-by-current-user")(if @message.staged "is-staged" "is-persisted")(if @message.deletedAt "is-deleted")+ (if (eq @message.id this.chat.activeMessage.model.id) "is-active")}}data-id={{@message.id}}data-thread-id={{@message.thread.id}}@@ -75,7 +76,6 @@(if this.hideUserInfo "user-info-hidden")(if @message.error "errored")(if @message.bookmark "chat-message-bookmarked")- (if (eq @message.id this.chat.activeMessage.model.id) "is-active")}}>{{#unless this.hideReplyToInfo}}diff --git a/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.js b/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.jsindex 397e137f956..7228b13cf4f 100644--- a/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.js+++ b/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.js@@ -42,7 +42,9 @@ export default class ChatOnLongPress extends Modifier {onCancel() {cancel(this.timeout);- this.element.removeEventListener("touchmove", this.onCancel);+ this.element.removeEventListener("touchmove", this.onCancel, {+ passive: true,+ });this.element.removeEventListener("touchend", this.onCancel);this.element.removeEventListener("touchcancel", this.onCancel);@@ -55,13 +57,12 @@ export default class ChatOnLongPress extends Modifier {this.onCancel();return;}-this.onLongPressStart(this.element, event);-- this.element.addEventListener("touchmove", this.onCancel);+ this.element.addEventListener("touchmove", this.onCancel, {+ passive: true,+ });this.element.addEventListener("touchend", this.onCancel);this.element.addEventListener("touchcancel", this.onCancel);-this.timeout = discourseLater(() => {if (this.isDestroying || this.isDestroyed) {return;@@ -69,6 +70,7 @@ export default class ChatOnLongPress extends Modifier {this.element.addEventListener("touchend", cancelEvent, {once: true,+ passive: true,});this.onLongPressEnd(this.element, event);@@ -80,6 +82,10 @@ export default class ChatOnLongPress extends Modifier {return;}+ this.element.removeEventListener("touchstart", this.handleTouchStart, {+ passive: true,+ });+this.onCancel();}}diff --git a/plugins/chat/assets/stylesheets/common/chat-message.scss b/plugins/chat/assets/stylesheets/common/chat-message.scssindex 13623a93d72..cc181ba877c 100644--- a/plugins/chat/assets/stylesheets/common/chat-message.scss+++ b/plugins/chat/assets/stylesheets/common/chat-message.scss@@ -21,7 +21,6 @@.chat-message {align-items: flex-start;padding: 0.25em 0.5em 0.25em 0.75em;- background-color: var(--secondary);display: flex;min-width: 0;@@ -214,15 +213,21 @@.chat-message-reaction-list .chat-message-react-btn {display: none;}+ }++ .chat-message-container {+ background-color: var(--secondary);.touch & {- &:active {+ &:active,+ &.is-active {background: var(--d-hover);border-radius: 5px;}&.chat-message-bookmarked {- &:active {+ &:active,+ &.is-active {background: var(--highlight-low);}}diff --git a/plugins/chat/assets/stylesheets/mobile/base-mobile.scss b/plugins/chat/assets/stylesheets/mobile/base-mobile.scssindex d44ae726388..06d1399a44d 100644--- a/plugins/chat/assets/stylesheets/mobile/base-mobile.scss+++ b/plugins/chat/assets/stylesheets/mobile/base-mobile.scss@@ -60,10 +60,6 @@ html.has-full-page-chat {height: 50px;min-height: 50px;}-- .chat-messages-scroll {- padding: 0 10px;- }}.sidebar-container .channels-list .chat-channel-divider {diff --git a/plugins/chat/assets/stylesheets/mobile/chat-channel.scss b/plugins/chat/assets/stylesheets/mobile/chat-channel.scssnew file mode 100644index 00000000000..ff846f1bac3--- /dev/null+++ b/plugins/chat/assets/stylesheets/mobile/chat-channel.scss@@ -0,0 +1,5 @@+.chat-channel {+ .chat-messages-scroll {+ padding: 0 10px 10px 10px;+ }+}diff --git a/plugins/chat/assets/stylesheets/mobile/chat-message-actions.scss b/plugins/chat/assets/stylesheets/mobile/chat-message-actions.scssindex d0c535fa02c..c5badb64ef3 100644--- a/plugins/chat/assets/stylesheets/mobile/chat-message-actions.scss+++ b/plugins/chat/assets/stylesheets/mobile/chat-message-actions.scss@@ -154,7 +154,7 @@height: 100%;width: 100%;z-index: z("header") + 1;- transition: background-color 0.4s ease;+ transition: background-color 0.4s ease-in;.collapse-area {width: 100%;@@ -162,7 +162,7 @@}&.fade-in {- background: rgba(var(--always-black-rgb), 0.75);+ background: rgba(var(--always-black-rgb), 0.6);.chat-message-actions {bottom: 0px;diff --git a/plugins/chat/assets/stylesheets/mobile/chat-message.scss b/plugins/chat/assets/stylesheets/mobile/chat-message.scssindex 4c2af11e28a..0197133c3fd 100644--- a/plugins/chat/assets/stylesheets/mobile/chat-message.scss+++ b/plugins/chat/assets/stylesheets/mobile/chat-message.scss@@ -1,12 +1,16 @@.mobile-view.has-full-page-chat {&.disable-message-actions-touch {- .chat-message-actions-backdrop {+ .chat-message-actions {> * {pointer-events: none;}}}+ #skip-link {+ @include user-select(none);+ }+#skip-link,.d-header,.chat-message-actions-mobile-outlet,diff --git a/plugins/chat/assets/stylesheets/mobile/index.scss b/plugins/chat/assets/stylesheets/mobile/index.scssindex d0bcc924e2b..9d15ac78433 100644--- a/plugins/chat/assets/stylesheets/mobile/index.scss+++ b/plugins/chat/assets/stylesheets/mobile/index.scss@@ -1,5 +1,6 @@@import "base-mobile";@import "chat-channel-info";+@import "chat-channel";@import "chat-composer";@import "chat-index";@import "chat-message-actions";diff --git a/plugins/chat/spec/system/chat_message/channel_spec.rb b/plugins/chat/spec/system/chat_message/channel_spec.rbindex ee5f1bb22ae..f3c438652b7 100644--- a/plugins/chat/spec/system/chat_message/channel_spec.rb+++ b/plugins/chat/spec/system/chat_message/channel_spec.rb@@ -22,7 +22,7 @@ RSpec.describe "Chat message - channel", type: :system dochannel.hover_message(message_1)expect(page).to have_css(- ".chat-channel[data-id='#{channel_1.id}'] [data-id='#{message_1.id}'] .chat-message.is-active",+ ".chat-channel[data-id='#{channel_1.id}'] .chat-message-container[data-id='#{message_1.id}'].is-active",)endenddiff --git a/plugins/chat/spec/system/chat_message/thread_spec.rb b/plugins/chat/spec/system/chat_message/thread_spec.rbindex c352987c692..d993eb1f14e 100644--- a/plugins/chat/spec/system/chat_message/thread_spec.rb+++ b/plugins/chat/spec/system/chat_message/thread_spec.rb@@ -30,7 +30,7 @@ RSpec.describe "Chat message - thread", type: :system dothread_page.hover_message(first_message)expect(page).to have_css(- ".chat-thread[data-id='#{thread_1.id}'] [data-id='#{first_message.id}'] .chat-message.is-active",+ ".chat-thread[data-id='#{thread_1.id}'] [data-id='#{first_message.id}'].chat-message-container.is-active",)endend