Skip to content

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

UX: Show topic navigation and floating reply button in embed mode (#39185)

Rafael dos Santos Silvaf6085a008ae2
diff --git a/app/assets/stylesheets/common/base/embed-mode.scss b/app/assets/stylesheets/common/base/embed-mode.scss
index ef4d227c5d4..2fbebe2b16d 100644
--- a/app/assets/stylesheets/common/base/embed-mode.scss
+++ b/app/assets/stylesheets/common/base/embed-mode.scss
@@ -27,7 +27,6 @@ body.embed-mode {
nav.post-controls .actions .show-more-actions,
.software-update-prompt,
.time-gap,
- .topic-navigation,
.post-stream .gap,
.container.posts:not(:has(.post-stream .topic-post ~ .topic-post))
~ #topic-footer-buttons {
@@ -97,6 +96,70 @@ body.embed-mode {
border-bottom: 1px solid var(--content-border-color);
}
+ // Single-column grid for embed mode (no timeline sidebar)
+ .container.posts {
+ grid-template-areas: "posts";
+ grid-template-columns: auto;
+ }
+
+ // Position the topic-navigation in the grid so progress bar appears after posts
+ .container.posts .topic-navigation {
+ grid-area: posts;
+ grid-row: 3;
+ display: flex;
+ justify-content: flex-end;
+
+ // Don't use sticky positioning — floating buttons handle the scrolling UX
+ &.with-topic-progress {
+ position: static;
+ }
+ }
+
+ // Hide the docked timeline sidebar (fullscreen timeline still works)
+ .timeline-container:not(.timeline-fullscreen) {
+ display: none !important;
+ }
+
+ // Hide admin menu in the progress bar for embed context
+ #topic-progress-wrapper .topic-admin-menu-trigger,
+ #topic-progress-wrapper .btn-toggle-localized-content {
+ display: none;
+ }
+
+ // Floating action buttons (timeline + reply) in the bottom-right
+ .embed-floating-buttons {
+ position: fixed;
+ bottom: calc(
+ env(safe-area-inset-bottom) + var(--composer-height, 0px) + 1em
+ );
+ right: var(--space-4);
+ z-index: z("timeline");
+ display: flex;
+ flex-direction: column;
+ gap: 0.65em;
+ align-items: center;
+
+ .embed-floating-timeline-button,
+ .embed-floating-reply-button {
+ width: 2.75em;
+ height: 2.75em;
+ border-radius: 50%;
+ padding: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ box-shadow: var(--shadow-dropdown);
+
+ .d-button-label {
+ display: none;
+ }
+
+ .d-icon {
+ margin: 0;
+ }
+ }
+ }
+
// Hide OP
// Use visibility hidden to prevent issues with jumpy behavior
.post-stream .topic-post.topic-owner:first-child {
diff --git a/frontend/discourse/app/components/embed-topic-footer.gjs b/frontend/discourse/app/components/embed-topic-footer.gjs
index 09a80e91ccd..aa7d713dde4 100644
--- a/frontend/discourse/app/components/embed-topic-footer.gjs
+++ b/frontend/discourse/app/components/embed-topic-footer.gjs
@@ -1,6 +1,8 @@
import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { service } from "@ember/service";
+import { modifier } from "ember-modifier";
import DButton from "discourse/components/d-button";
import PoweredByDiscourse from "discourse/components/powered-by-discourse";
import icon from "discourse/helpers/d-icon";
@@ -10,10 +12,39 @@ import Composer from "discourse/models/composer";
import { i18n } from "discourse-i18n";
export default class EmbedTopicFooter extends Component {
+ @service appEvents;
@service composer;
@service currentUser;
@service siteSettings;
+ @tracked footerButtonsVisible = false;
+
+ trackFooterVisibility = modifier((element) => {
+ const footerButtons = document.querySelector("#topic-footer-buttons");
+ const targets = [footerButtons, element].filter(Boolean);
+
+ if (targets.length === 0) {
+ return;
+ }
+
+ const visibilityMap = new Map();
+ targets.forEach((t) => visibilityMap.set(t, false));
+
+ const observer = new IntersectionObserver(
+ (entries) => {
+ entries.forEach((entry) => {
+ visibilityMap.set(entry.target, entry.isIntersecting);
+ });
+ this.footerButtonsVisible = [...visibilityMap.values()].some(Boolean);
+ },
+ { threshold: 0 }
+ );
+
+ targets.forEach((t) => observer.observe(t));
+
+ return () => observer.disconnect();
+ });
+
get isEmbedMode() {
return EmbedMode.enabled;
}
@@ -30,6 +61,25 @@ export default class EmbedTopicFooter extends Component {
return this.currentUser ? "topic.reply.title" : "topic.login_reply";
}
+ get showFloatingReplyButton() {
+ return (
+ this.args.topic?.details?.can_create_post && !this.footerButtonsVisible
+ );
+ }
+
+ get showFloatingTimelineButton() {
+ return this.args.topic?.replyCount > 0 && !this.footerButtonsVisible;
+ }
+
+ get showFloatingButtons() {
+ return this.showFloatingReplyButton || this.showFloatingTimelineButton;
+ }
+
+ @action
+ handleTimelineToggle() {
+ this.appEvents.trigger("topic:toggle-progress-expansion");
+ }
+
@action
async handleReply() {
if (!this.currentUser) {
@@ -52,7 +102,7 @@ export default class EmbedTopicFooter extends Component {
<template>
{{#if this.isEmbedMode}}
- <div class="embed-topic-footer">
+ <div class="embed-topic-footer" {{this.trackFooterVisibility}}>
{{#if this.showFirstReplyMessage}}
<div class="embed-topic-footer__first-reply">
{{icon "comment"}}
@@ -70,6 +120,26 @@ export default class EmbedTopicFooter extends Component {
</div>
{{/if}}
</div>
+ {{#if this.showFloatingButtons}}
+ <div class="embed-floating-buttons">
+ {{#if this.showFloatingTimelineButton}}
+ <DButton
+ @action={{this.handleTimelineToggle}}
+ @icon="bars-staggered"
+ @title="topic.progress.title"
+ class="btn-default embed-floating-timeline-button"
+ />
+ {{/if}}
+ {{#if this.showFloatingReplyButton}}
+ <DButton
+ @action={{this.handleReply}}
+ @icon="reply"
+ @title={{this.replyButtonLabel}}
+ class="btn-primary embed-floating-reply-button"
+ />
+ {{/if}}
+ </div>
+ {{/if}}
{{/if}}
</template>
}
diff --git a/frontend/discourse/app/components/topic-navigation.gjs b/frontend/discourse/app/components/topic-navigation.gjs
index d3b0cd25a96..5f8707d6bc1 100644
--- a/frontend/discourse/app/components/topic-navigation.gjs
+++ b/frontend/discourse/app/components/topic-navigation.gjs
@@ -8,6 +8,7 @@ import { observes } from "@ember-decorators/object";
import $ from "jquery";
import discourseDebounce from "discourse/lib/debounce";
import { bind } from "discourse/lib/decorators";
+import EmbedMode from "discourse/lib/embed-mode";
import discourseLater from "discourse/lib/later";
import { headerOffset } from "discourse/lib/offset-calculator";
import SwipeEvents from "discourse/lib/swipe-events";
@@ -52,7 +53,7 @@ export default class TopicNavigation extends Component {
if (this.info.topicProgressExpanded) {
this.info.set("renderTimeline", true);
- } else if (this.site.mobileView) {
+ } else if (this.site.mobileView || EmbedMode.enabled) {
this.info.set("renderTimeline", false);
} else {
const composerHeight =
@@ -121,6 +122,11 @@ export default class TopicNavigation extends Component {
this._checkSize();
}
+ @bind
+ _toggleExpansion() {
+ this.info.toggleProperty("topicProgressExpanded");
+ }
+
_collapseFullscreen(postId, delay = 500) {
if (this.get("info.topicProgressExpanded")) {
$(".timeline-fullscreen").removeClass("show");
@@ -231,7 +237,8 @@ export default class TopicNavigation extends Component {
this.appEvents
.on("topic:current-post-scrolled", this, this._topicScrolled)
.on("topic:jump-to-post", this, this._collapseFullscreen)
- .on("topic:keyboard-trigger", this, this.keyboardTrigger);
+ .on("topic:keyboard-trigger", this, this.keyboardTrigger)
+ .on("topic:toggle-progress-expansion", this, this._toggleExpansion);
if (this.site.desktopView) {
this._desktopListenersActive = true;
@@ -262,7 +269,8 @@ export default class TopicNavigation extends Component {
this.appEvents
.off("topic:current-post-scrolled", this, this._topicScrolled)
.off("topic:jump-to-post", this, this._collapseFullscreen)
- .off("topic:keyboard-trigger", this, this.keyboardTrigger);
+ .off("topic:keyboard-trigger", this, this.keyboardTrigger)
+ .off("topic:toggle-progress-expansion", this, this._toggleExpansion);
$(window).off("click.hide-fullscreen");
diff --git a/spec/system/embed_mode_spec.rb b/spec/system/embed_mode_spec.rb
index c4337d0633f..485fc619c1b 100644
--- a/spec/system/embed_mode_spec.rb
+++ b/spec/system/embed_mode_spec.rb
@@ -28,6 +28,12 @@ describe "Embed mode" do
expect(page).to have_no_css(".suggested-topics")
end
+ it "shows the topic navigation widget" do
+ visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
+
+ expect(page).to have_css(".topic-navigation")
+ end
+
it "loads topic content without JS errors" do
visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
@@ -95,6 +101,12 @@ describe "Embed mode" do
expect(page).to have_no_css("#reply-control.open")
expect(page).to have_no_css("#reply-control.fullscreen")
end
+
+ it "does not show floating timeline button" do
+ visit("/t/#{no_reply_topic.slug}/#{no_reply_topic.id}?embed_mode=true")
+
+ expect(topic_page).to have_no_floating_timeline_button
+ end
end
context "with a topic that has replies" do
@@ -114,6 +126,42 @@ describe "Embed mode" do
expect(page).to have_css("#reply-control.open")
end
+ context "with many replies" do
+ before { 15.times { Fabricate(:post, topic: topic) } }
+
+ it "shows floating action buttons when footer is not visible" do
+ visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
+ expect(topic_page).to have_post_number(2)
+
+ expect(topic_page).to have_floating_reply_button
+ expect(topic_page).to have_floating_timeline_button
+ end
+
+ it "opens the composer when clicking the floating reply button" do
+ visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
+ expect(topic_page).to have_post_number(2)
+
+ topic_page.click_floating_reply_button
+ expect(page).to have_css("#reply-control.open")
+ end
+
+ it "opens the timeline when clicking the floating timeline button" do
+ visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
+ expect(topic_page).to have_post_number(2)
+
+ topic_page.click_floating_timeline_button
+ expect(page).to have_css(".timeline-fullscreen.show")
+ end
+
+ it "shows the topic progress bar at the bottom (not sticky)" do
+ visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
+ expect(topic_page).to have_post_number(2)
+
+ expect(page).to have_css("#topic-progress-wrapper", visible: :visible)
+ expect(page).to have_css(".topic-navigation.with-topic-progress", visible: :visible)
+ end
+ end
+
it "does not show 'be the first to reply' message" do
visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
diff --git a/spec/system/page_objects/pages/topic.rb b/spec/system/page_objects/pages/topic.rb
index b4e42eb1b63..2faeb03a646 100644
--- a/spec/system/page_objects/pages/topic.rb
+++ b/spec/system/page_objects/pages/topic.rb
@@ -237,6 +237,31 @@ module PageObjects
has_expanded_composer?
end
+ def click_floating_reply_button
+ find(".embed-floating-reply-button").click
+ has_expanded_composer?
+ end
+
+ def has_floating_reply_button?
+ has_css?(".embed-floating-reply-button")
+ end
+
+ def has_no_floating_reply_button?
+ has_no_css?(".embed-floating-reply-button")
+ end
+
+ def click_floating_timeline_button
+ find(".embed-floating-timeline-button").click
+ end
+
+ def has_floating_timeline_button?
+ has_css?(".embed-floating-timeline-button")
+ end
+
+ def has_no_floating_timeline_button?
+ has_no_css?(".embed-floating-timeline-button")
+ end
+
def has_expanded_composer?
has_css?("#reply-control.open")
end