diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs
index 0ad94728c19..b00f0efc748 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs
@@ -24,7 +24,7 @@
{
- this.popper = createPopper(
- chatMessageContainer(this.message.id, this.context),
- element,
- {
- placement: "top-end",
- strategy: "fixed",
- modifiers: [
- { name: "hide", enabled: true },
- { name: "eventListeners", options: { scroll: false } },
- {
- name: "offset",
- options: { offset: [-2, MSG_ACTIONS_VERTICAL_PADDING] },
- },
- ],
- }
+ const messageContainer = chatMessageContainer(
+ this.message.id,
+ this.context
);
+
+ this.popper = createPopper(messageContainer, element, {
+ placement: "top-end",
+ strategy: "fixed",
+ modifiers: [
+ {
+ name: "flip",
+ enabled: true,
+ options: {
+ boundary: messageContainer.closest(".popper-viewport"),
+ fallbackPlacements: ["bottom-end"],
+ },
+ },
+ { name: "hide", enabled: true },
+ { name: "eventListeners", options: { scroll: false } },
+ {
+ name: "offset",
+ options: { offset: [-2, MSG_ACTIONS_VERTICAL_PADDING] },
+ },
+ ],
+ });
});
}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbs
index a2e29d499ad..61e6df014c3 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbs
@@ -15,7 +15,10 @@
-