Skip to content

A platform for community discussion. Free, open, simple.

DEV: remove stacking context fix (#35231)

Joffrey JAFFEUX44c1d1a3db6b
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
index 70f0daa3d5a..0eba05f0155 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
@@ -35,7 +35,6 @@ import {
scrollListToMessage,
} from "discourse/plugins/chat/discourse/lib/scroll-helpers";
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
-import { stackingContextFix } from "../lib/chat-ios-hacks";
import ChatComposerChannel from "./chat/composer/channel";
import ChatScrollToBottomArrow from "./chat/scroll-to-bottom-arrow";
import ChatSelectionManager from "./chat/selection-manager";
@@ -173,9 +172,7 @@ export default class ChatChannel extends Component {
return;
}
- stackingContextFix(this.scroller, () => {
- this.messagesManager.addMessages([message]);
- });
+ this.messagesManager.addMessages([message]);
this.debouncedUpdateLastReadMessage();
}
@@ -237,9 +234,7 @@ export default class ChatChannel extends Component {
}
const targetMessageId = this.messagesManager.messages.lastObject.id;
- stackingContextFix(this.scroller, () => {
- this.messagesManager.addMessages(messages);
- });
+ this.messagesManager.addMessages(messages);
if (direction === FUTURE && !opts.noScroll) {
this.scrollToMessageId(targetMessageId, {
@@ -534,9 +529,7 @@ export default class ChatChannel extends Component {
this.resetComposerMessage();
try {
- stackingContextFix(this.scroller, async () => {
- await this.chatApi.editMessage(this.args.channel.id, message.id, data);
- });
+ await this.chatApi.editMessage(this.args.channel.id, message.id, data);
} catch (e) {
popupAjaxError(e);
} finally {
@@ -548,9 +541,7 @@ export default class ChatChannel extends Component {
async #sendNewMessage(message) {
this.pane.sending = true;
- stackingContextFix(this.scroller, async () => {
- await this.args.channel.stageMessage(message);
- });
+ await this.args.channel.stageMessage(message);
message.manager = this.args.channel.messagesManager;
this.resetComposerMessage();
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs
index 97a7cf33516..ca87639dc2c 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs
@@ -20,7 +20,6 @@ import {
PAST,
READ_INTERVAL_MS,
} from "discourse/plugins/chat/discourse/lib/chat-constants";
-import { stackingContextFix } from "discourse/plugins/chat/discourse/lib/chat-ios-hacks";
import ChatMessagesLoader from "discourse/plugins/chat/discourse/lib/chat-messages-loader";
import DatesSeparatorsPositioner from "discourse/plugins/chat/discourse/lib/dates-separators-positioner";
import { extractCurrentTopicInfo } from "discourse/plugins/chat/discourse/lib/extract-current-topic-info";
@@ -236,9 +235,7 @@ export default class ChatThread extends Component {
}
const [messages, meta] = this.processMessages(this.args.thread, result);
- stackingContextFix(this.scroller, () => {
- this.messagesManager.addMessages(messages);
- });
+ this.messagesManager.addMessages(messages);
this.args.thread.details = meta;
if (meta.target_message_id) {
@@ -266,9 +263,7 @@ export default class ChatThread extends Component {
return;
}
- stackingContextFix(this.scroller, () => {
- this.messagesManager.addMessages(messages);
- });
+ this.messagesManager.addMessages(messages);
this.args.thread.details = meta;
if (direction === FUTURE) {
@@ -339,9 +334,7 @@ export default class ChatThread extends Component {
return;
}
- stackingContextFix(this.scroller, () => {
- this.messagesManager.addMessages([message]);
- });
+ this.messagesManager.addMessages([message]);
}
@bind
@@ -436,9 +429,7 @@ export default class ChatThread extends Component {
this.chatThreadPane.sending = true;
this._ignoreNextScroll = true;
- stackingContextFix(this.scroller, async () => {
- await this.args.thread.stageMessage(message);
- });
+ await this.args.thread.stageMessage(message);
this.resetComposerMessage();
if (!this.messagesLoader.canLoadMoreFuture) {
diff --git a/plugins/chat/assets/javascripts/discourse/lib/chat-ios-hacks.js b/plugins/chat/assets/javascripts/discourse/lib/chat-ios-hacks.js
deleted file mode 100644
index ba3d948a2a5..00000000000
--- a/plugins/chat/assets/javascripts/discourse/lib/chat-ios-hacks.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import { capabilities } from "discourse/services/capabilities";
-
-// since -webkit-overflow-scrolling: touch can't be used anymore to disable momentum scrolling
-// we use different hacks to work around this
-// if you change any line in this method, make sure to test on iOS
-export function stackingContextFix(scrollable, callback) {
- callback?.();
-
- if (capabilities.isIOS) {
- // stores scroll position otherwise we will lose it
- const currentScroll = scrollable.scrollTop;
-
- const display = scrollable.style.display;
- scrollable.style.display = "none"; // forces redraw on the container
- scrollable.offsetHeight; // triggers a reflow
- scrollable.style.display = display;
-
- scrollable.scrollTop = currentScroll;
- }
-}
diff --git a/plugins/chat/assets/javascripts/discourse/lib/scroll-helpers.js b/plugins/chat/assets/javascripts/discourse/lib/scroll-helpers.js
index e93d5c9e6af..72df8a99817 100644
--- a/plugins/chat/assets/javascripts/discourse/lib/scroll-helpers.js
+++ b/plugins/chat/assets/javascripts/discourse/lib/scroll-helpers.js
@@ -1,21 +1,16 @@
import { next, schedule } from "@ember/runloop";
-import { stackingContextFix } from "discourse/plugins/chat/discourse/lib/chat-ios-hacks";
export async function scrollListToBottom(list) {
await new Promise((resolve) => {
- stackingContextFix(list, () => {
- list.scrollTo({ top: 0, behavior: "auto" });
- next(resolve);
- });
+ list.scrollTo({ top: 0, behavior: "auto" });
+ next(resolve);
});
}
export async function scrollListToTop(list) {
await new Promise((resolve) => {
- stackingContextFix(list, () => {
- list.scrollTo({ top: -list.scrollHeight, behavior: "auto" });
- next(resolve);
- });
+ list.scrollTo({ top: -list.scrollHeight, behavior: "auto" });
+ next(resolve);
});
}
@@ -45,11 +40,9 @@ export function scrollListToMessage(
message.highlight();
}
- stackingContextFix(list, () => {
- messageEl.scrollIntoView({
- behavior: "auto",
- block: opts.position || "center",
- });
+ messageEl.scrollIntoView({
+ behavior: "auto",
+ block: opts.position || "center",
});
});
}