Skip to content

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

FEATURE: Use `DockedComposer` for replies in embed mode (#39352)

Keegan Georged62ed1d2d1a0
diff --git a/app/assets/stylesheets/common/base/embed-mode.scss b/app/assets/stylesheets/common/base/embed-mode.scss
index 0ea6f82cba5..6414e1d46a6 100644
--- a/app/assets/stylesheets/common/base/embed-mode.scss
+++ b/app/assets/stylesheets/common/base/embed-mode.scss
@@ -39,22 +39,9 @@ body.embed-mode {
max-width: 100%;
}
- // Composer styling for embed mode
- &:not(.has-sidebar-page) #reply-control:not(.fullscreen),
+ // Hide the standard composer in embed mode — the docked composer replaces it
#reply-control {
- margin-inline: 0;
- margin-left: 0;
- max-width: 100%;
- border-radius: 0;
- border-top-left-radius: 0;
- border-top-right-radius: 0;
- border-bottom: none;
- border-right: none;
- border-left: none;
-
- .composer-action-title {
- display: none;
- }
+ display: none !important;
}
.embed-topic-footer {
@@ -127,21 +114,14 @@ body.embed-mode {
display: none;
}
- // Floating action buttons (timeline + reply) in the bottom-right
+ // Floating timeline button in the bottom-right
.embed-floating-buttons {
position: fixed;
- bottom: calc(
- env(safe-area-inset-bottom) + var(--composer-height, 0px) + 1em
- );
+ bottom: calc(env(safe-area-inset-bottom) + 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 {
+ .embed-floating-timeline-button {
width: 2.75em;
height: 2.75em;
border-radius: 50%;
@@ -170,4 +150,45 @@ body.embed-mode {
position: absolute;
pointer-events: none;
}
+
+ .embed-mode-composer {
+ position: sticky;
+ bottom: 0;
+ z-index: 50;
+ background: var(--secondary);
+ padding-inline: 0.5em;
+
+ .docked-composer {
+ --docked-composer-input-min-height: 10em;
+ margin-top: 0;
+ }
+
+ .embed-floating-buttons {
+ position: absolute;
+ bottom: 100%;
+ right: var(--space-4);
+ z-index: z("timeline");
+ padding-bottom: 0.5em;
+ }
+
+ &__replying-to {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0.35em 0.75em;
+ font-size: var(--font-down-1);
+ color: var(--primary-medium);
+ border-top: 1px solid var(--primary-low);
+ }
+
+ &__replying-to-text {
+ display: flex;
+ align-items: center;
+ gap: 0.35em;
+ }
+
+ &__replying-to-dismiss {
+ padding: 0.25em;
+ }
+ }
}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index e08f4fed563..2681f5e56cf 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -721,6 +721,8 @@ en:
allow_access: "Allow Access"
continue_as_guest: "Continue as Guest"
be_first_to_reply: "Be the first to reply!"
+ replying_to: "Replying to %{username}"
+ reply_placeholder: "Write a reply..."
topic_count_all:
one: "See %{count} new topic"
diff --git a/frontend/discourse/app/components/docked-composer.gjs b/frontend/discourse/app/components/docked-composer.gjs
index 7f183825aba..2a00a58fec2 100644
--- a/frontend/discourse/app/components/docked-composer.gjs
+++ b/frontend/discourse/app/components/docked-composer.gjs
@@ -45,6 +45,12 @@ export default class DockedComposer extends Component {
#dragStart = null;
#rootElement = null;
+ #handleInput = (event) => {
+ const value = event?.target?.value ?? "";
+ this.reply = value;
+ this.persistDraft(value);
+ };
+
#handlePaste = (event) => {
if (!this.textarea || document.activeElement !== this.textarea) {
return;
@@ -143,6 +149,7 @@ export default class DockedComposer extends Component {
// capture phase so Enter-to-send wins over ItsATrap / smart-list handlers
this.textarea.addEventListener("keydown", this.#handleKeyDown, true);
this.textarea.addEventListener("paste", this.#handlePaste);
+ this.textarea.addEventListener("input", this.#handleInput);
}
}
@@ -198,6 +205,7 @@ export default class DockedComposer extends Component {
teardown() {
this.textarea?.removeEventListener("keydown", this.#handleKeyDown, true);
this.textarea?.removeEventListener("paste", this.#handlePaste);
+ this.textarea?.removeEventListener("input", this.#handleInput);
this.uppyUpload?.teardown();
this.#rootElement = null;
}
diff --git a/frontend/discourse/app/components/embed-mode-composer.gjs b/frontend/discourse/app/components/embed-mode-composer.gjs
new file mode 100644
index 00000000000..646ff347dfc
--- /dev/null
+++ b/frontend/discourse/app/components/embed-mode-composer.gjs
@@ -0,0 +1,225 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import { schedule } from "@ember/runloop";
+import { service } from "@ember/service";
+import { modifier } from "ember-modifier";
+import DButton from "discourse/components/d-button";
+import DockedComposer from "discourse/components/docked-composer";
+import avatar from "discourse/helpers/avatar";
+import EmbedMode from "discourse/lib/embed-mode";
+import { i18n } from "discourse-i18n";
+
+export default class EmbedModeComposer extends Component {
+ @service appEvents;
+ @service currentUser;
+ @service site;
+ @service store;
+
+ @tracked replyingToPost = null;
+ @tracked isSubmitting = false;
+ @tracked footerVisible = true;
+
+ setupEvents = modifier((element) => {
+ this.#rootElement = element;
+ this.appEvents.on(
+ "embed-composer:reply-to-post",
+ this,
+ this.handleReplyToPost
+ );
+ this.appEvents.on("embed-composer:focus", this, this.handleFocus);
+
+ const footerButtons = document.querySelector("#topic-footer-buttons");
+ const embedFooter = document.querySelector(".embed-topic-footer");
+ const targets = [footerButtons, embedFooter].filter(Boolean);
+
+ if (targets.length > 0) {
+ const visibilityMap = new Map();
+ targets.forEach((t) => visibilityMap.set(t, false));
+
+ this.#footerObserver = new IntersectionObserver(
+ (entries) => {
+ entries.forEach((entry) => {
+ visibilityMap.set(entry.target, entry.isIntersecting);
+ });
+ this.footerVisible = [...visibilityMap.values()].some(Boolean);
+ },
+ { threshold: 0 }
+ );
+
+ targets.forEach((t) => this.#footerObserver.observe(t));
+ }
+
+ return () => {
+ this.#rootElement = null;
+ this.#footerObserver?.disconnect();
+ this.appEvents.off(
+ "embed-composer:reply-to-post",
+ this,
+ this.handleReplyToPost
+ );
+ this.appEvents.off("embed-composer:focus", this, this.handleFocus);
+ };
+ });
+ #footerObserver = null;
+ #rootElement = null;
+
+ get show() {
+ if (!EmbedMode.enabled) {
+ return false;
+ }
+ return this.currentUser && this.args.topic?.details?.can_create_post;
+ }
+
+ get showFloatingTimelineButton() {
+ return this.args.topic?.replyCount > 0 && !this.footerVisible;
+ }
+
+ get draftKey() {
+ return `embed-reply-${this.args.topic?.id}`;
+ }
+
+ get placeholder() {
+ return i18n("embed_mode.reply_placeholder");
+ }
+
+ @action
+ handleReplyToPost(post) {
+ if (post && post.post_number !== 1) {
+ this.replyingToPost = post;
+ } else {
+ this.replyingToPost = null;
+ }
+ schedule("afterRender", () => {
+ this.#rootElement?.querySelector(".d-editor-input")?.focus();
+ });
+ }
+
+ @action
+ handleFocus() {
+ this.#rootElement?.querySelector(".d-editor-input")?.focus();
+ }
+
+ @action
+ handleTimelineToggle() {
+ this.appEvents.trigger("topic:toggle-progress-expansion");
+ }
+
+ @action
+ clearReplyingTo() {
+ this.replyingToPost = null;
+ }
+
+ @action
+ async handleSubmit({ raw }) {
+ const topic = this.args.topic;
+ const postStream = topic.postStream;
+ const user = this.currentUser;
+
+ this.isSubmitting = true;
+
+ const createdPost = this.store.createRecord("post", {
+ raw,
+ topic_id: topic.id,
+ reply_to_post_number: this.replyingToPost?.post_number,
+ nested_post: true,
+ draft_key: topic.draft_key,
+ reply_count: 0,
+ name: user.name,
+ display_username: user.name,
+ username: user.username,
+ user_id: user.id,
+ user_title: user.title,
+ avatar_template: user.avatar_template,
+ user_custom_fields: user.custom_fields,
+ post_type: this.site.post_types.regular,
+ actions_summary: [],
+ moderator: user.moderator,
+ admin: user.admin,
+ yours: true,
+ read: true,
+ wiki: false,
+ });
+
+ if (this.replyingToPost) {
+ createdPost.setProperties({
+ reply_to_post_number: this.replyingToPost.post_number,
+ reply_to_user: {
+ username: this.replyingToPost.username,
+ avatar_template: this.replyingToPost.avatar_template,
+ },
+ });
+ }
+
+ const state = postStream.stagePost(createdPost, user);
+ if (state === "alreadyStaging") {
+ this.isSubmitting = false;
+ return false;
+ }
+
+ try {
+ await createdPost.save();
+ postStream.commitPost(createdPost);
+ topic.set("posts_count", (topic.posts_count || 0) + 1);
+
+ if (this.replyingToPost) {
+ this.replyingToPost.setProperties({
+ reply_count: (this.replyingToPost.reply_count || 0) + 1,
+ replies: [],
+ });
+ }
+
+ this.replyingToPost = null;
+ this.isSubmitting = false;
+ return { ok: true };
+ } catch (error) {
+ postStream.undoPost(createdPost);
+ this.isSubmitting = false;
+ throw error;
+ }
+ }
+
+ <template>
+ {{#if this.show}}
+ <div class="embed-mode-composer" {{this.setupEvents}}>
+ {{#if this.showFloatingTimelineButton}}
+ <div class="embed-floating-buttons">
+ <DButton
+ @action={{this.handleTimelineToggle}}
+ @icon="bars-staggered"
+ @title="topic.progress.title"
+ class="btn-default embed-floating-timeline-button"
+ />
+ </div>
+ {{/if}}
+ {{#if this.replyingToPost}}
+ <div class="embed-mode-composer__replying-to">
+ <span class="embed-mode-composer__replying-to-text">
+ {{avatar this.replyingToPost imageSize="tiny"}}
+ {{i18n
+ "embed_mode.replying_to"
+ username=this.replyingToPost.username
+ }}
+ </span>
+ <DButton
+ @icon="xmark"
+ @action={{this.clearReplyingTo}}
+ class="btn-transparent embed-mode-composer__replying-to-dismiss"
+ />
+ </div>
+ {{/if}}
+ <DockedComposer
+ @topicId={{@topic.id}}
+ @categoryId={{@topic.category.id}}
+ @onSubmit={{this.handleSubmit}}
+ @isSubmitting={{this.isSubmitting}}
+ @resizable={{true}}
+ @placeholder={{this.placeholder}}
+ @draftKey={{this.draftKey}}
+ @bodyClassName="embed-docked-composer-open"
+ @class="embed-mode-composer__composer"
+ />
+ </div>
+ {{/if}}
+ </template>
+}
diff --git a/frontend/discourse/app/components/embed-topic-footer.gjs b/frontend/discourse/app/components/embed-topic-footer.gjs
index aa7d713dde4..789cd8642ee 100644
--- a/frontend/discourse/app/components/embed-topic-footer.gjs
+++ b/frontend/discourse/app/components/embed-topic-footer.gjs
@@ -8,12 +8,10 @@ import PoweredByDiscourse from "discourse/components/powered-by-discourse";
import icon from "discourse/helpers/d-icon";
import EmbedMode from "discourse/lib/embed-mode";
import getURL from "discourse/lib/get-url";
-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;
@@ -61,27 +59,20 @@ 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() {
+ if (this.currentUser) {
+ return false;
+ }
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() {
+ handleReply() {
if (!this.currentUser) {
window.open(getURL("/login"), "_blank");
return;
@@ -92,12 +83,7 @@ export default class EmbedTopicFooter extends Component {
return;
}
- await this.composer.open({
- action: Composer.REPLY,
- topic,
- draftKey: topic.draft_key,
- draftSequence: topic.draft_sequence,
- });
+ this.appEvents.trigger("embed-composer:reply-to-post", null);
}
<template>
@@ -120,24 +106,14 @@ export default class EmbedTopicFooter extends Component {
</div>
{{/if}}
</div>
- {{#if this.showFloatingButtons}}
+ {{#if this.showFloatingTimelineButton}}
<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}}
+ <DButton
+ @action={{this.handleTimelineToggle}}
+ @icon="bars-staggered"
+ @title="topic.progress.title"
+ class="btn-default embed-floating-timeline-button"
+ />
</div>
{{/if}}
{{/if}}
diff --git a/frontend/discourse/app/controllers/topic.js b/frontend/discourse/app/controllers/topic.js
index b7dc26df836..4b87fcd85d9 100644
--- a/frontend/discourse/app/controllers/topic.js
+++ b/frontend/discourse/app/controllers/topic.js
@@ -28,6 +28,7 @@ import {
import { BookmarkFormData } from "discourse/lib/bookmark-form-data";
import { resetCachedTopicList } from "discourse/lib/cached-topic-list";
import { bind } from "discourse/lib/decorators";
+import EmbedMode from "discourse/lib/embed-mode";
import { isTesting } from "discourse/lib/environment";
import { wantsNewWindow } from "discourse/lib/intercept-click";
import discourseLater from "discourse/lib/later";
@@ -589,6 +590,15 @@ export default class TopicController extends Controller {
: this.get("model.postStream").loadPost(postId);
return promise.then(async (post) => {
+ if (EmbedMode.enabled) {
+ const quotedText = buildQuote(post, buffer, opts);
+ this.appEvents.trigger("embed-composer:reply-to-post", post);
+ if (quotedText?.trim()) {
+ this.appEvents.trigger("composer:insert-block", quotedText);
+ }
+ return;
+ }
+
const composer = this.composer;
const viewOpen = composer.get("model.viewOpen");
@@ -832,7 +842,6 @@ export default class TopicController extends Controller {
// Post related methods
@action
async replyToPost(post) {
- const composerController = this.composer;
const topic = post ? post.get("topic") : this.model;
const quoteState = this.quoteState;
const postStream = this.get("model.postStream");
@@ -843,6 +852,23 @@ export default class TopicController extends Controller {
return;
}
+ if (EmbedMode.enabled) {
+ const quotedPost = postStream.findLoadedPost(quoteState.postId);
+ const quotedText = buildQuote(
+ quotedPost,
+ quoteState.buffer,
+ quoteState.opts
+ );
+ quoteState.clear();
+
+ this.appEvents.trigger("embed-composer:reply-to-post", post);
+ if (quotedText?.trim()) {
+ this.appEvents.trigger("composer:insert-block", quotedText.trim());
+ }
+ return false;
+ }
+
+ const composerController = this.composer;
const quotedPost = postStream.findLoadedPost(quoteState.postId);
const quotedText = buildQuote(
quotedPost,
diff --git a/frontend/discourse/app/instance-initializers/embed-mode-composer.js b/frontend/discourse/app/instance-initializers/embed-mode-composer.js
index 5c83f9fe0be..85d8e80efd4 100644
--- a/frontend/discourse/app/instance-initializers/embed-mode-composer.js
+++ b/frontend/discourse/app/instance-initializers/embed-mode-composer.js
@@ -2,42 +2,18 @@ import { USER_OPTION_COMPOSITION_MODES } from "discourse/lib/constants";
import EmbedMode from "discourse/lib/embed-mode";
import { withPluginApi } from "discourse/lib/plugin-api";
-const EMBED_COMPOSER_HEIGHT = "50dvh";
-
-function setEmbedComposerHeight() {
- document.documentElement.style.setProperty(
- "--composer-height",
- EMBED_COMPOSER_HEIGHT
- );
-}
-
export default {
after: "inject-objects",
- initialize(owner) {
+ initialize() {
if (!EmbedMode.enabled) {
return;
}
- this._owner = owner;
- this._handler = setEmbedComposerHeight;
-
- owner.lookup("service:app-events").on("composer:open", this._handler);
-
withPluginApi((api) => {
api.registerValueTransformer("composer-force-editor-mode", () => {
return USER_OPTION_COMPOSITION_MODES.rich;
});
});
},
-
- teardown() {
- if (this._handler) {
- this._owner
- .lookup("service:app-events")
- .off("composer:open", this._handler);
- this._handler = null;
- this._owner = null;
- }
- },
};
diff --git a/frontend/discourse/app/routes/topic/from-params.js b/frontend/discourse/app/routes/topic/from-params.js
index 699ffdc402a..529e929831e 100644
--- a/frontend/discourse/app/routes/topic/from-params.js
+++ b/frontend/discourse/app/routes/topic/from-params.js
@@ -5,7 +5,6 @@ import { isEmpty } from "@ember/utils";
import EmbedMode from "discourse/lib/embed-mode";
import { isTesting } from "discourse/lib/environment";
import DiscourseURL from "discourse/lib/url";
-import Composer from "discourse/models/composer";
import Draft from "discourse/models/draft";
import DiscourseRoute from "discourse/routes/discourse";
@@ -143,7 +142,7 @@ export default class TopicFromParams extends DiscourseRoute {
closestPost.clearBookmark();
}
- if (!isEmpty(topic.draft)) {
+ if (!isEmpty(topic.draft) && !EmbedMode.enabled) {
this.composer.open({
draft: Draft.getLocal(topic.draft_key, topic.draft),
draftKey: topic.draft_key,
@@ -151,20 +150,6 @@ export default class TopicFromParams extends DiscourseRoute {
ignoreIfChanged: true,
topic,
});
- } else if (
- EmbedMode.enabled &&
- this.currentUser &&
- topic.replyCount === 0 &&
- topic.get("details.can_create_post")
- ) {
- schedule("afterRender", () => {
- this.composer.open({
- action: Composer.REPLY,
- draftKey: topic.draft_key,
- draftSequence: topic.draft_sequence,
- topic,
- });
- });
}
}
diff --git a/frontend/discourse/app/templates/topic.gjs b/frontend/discourse/app/templates/topic.gjs
index 7c81a4db3c6..647efeb8c0f 100644
--- a/frontend/discourse/app/templates/topic.gjs
+++ b/frontend/discourse/app/templates/topic.gjs
@@ -11,6 +11,7 @@ import CookText from "discourse/components/cook-text";
import DButton from "discourse/components/d-button";
import DiscourseBanner from "discourse/components/discourse-banner";
import DiscourseTopic from "discourse/components/discourse-topic";
+import EmbedModeComposer from "discourse/components/embed-mode-composer";
import EmbedTopicFooter from "discourse/components/embed-topic-footer";
import MoreTopics from "discourse/components/more-topics";
import PluginOutlet from "discourse/components/plugin-outlet";
@@ -627,8 +628,9 @@ export default <template>
@name="topic-below-suggested"
@outletArgs={{lazyHash [email protected]}}
/>
- <EmbedTopicFooter @topic={{@controller.model}} />
{{/if}}
+ <EmbedTopicFooter @topic={{@controller.model}} />
+ <EmbedModeComposer @topic={{@controller.model}} />
{{else}}
<div class="container">
<ConditionalLoadingSpinner @condition={{@controller.noErrorYet}}>
diff --git a/spec/system/embed_mode_spec.rb b/spec/system/embed_mode_spec.rb
index 485fc619c1b..586e5e1da6f 100644
--- a/spec/system/embed_mode_spec.rb
+++ b/spec/system/embed_mode_spec.rb
@@ -70,8 +70,7 @@ describe "Embed mode" do
end
context "when logged in" do
- fab!(:user)
- let(:composer) { PageObjects::Components::Composer.new }
+ fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
before do
SiteSetting.rich_editor = true
@@ -82,24 +81,16 @@ describe "Embed mode" do
fab!(:no_reply_topic, :topic)
fab!(:no_reply_post) { Fabricate(:post, topic: no_reply_topic) }
- it "auto-opens the composer" do
+ it "shows the docked composer" do
visit("/t/#{no_reply_topic.slug}/#{no_reply_topic.id}?embed_mode=true")
- expect(page).to have_css("#reply-control.open")
+ expect(topic_page).to have_docked_composer
end
- it "uses the rich text editor" do
- visit("/t/#{no_reply_topic.slug}/#{no_reply_topic.id}?embed_mode=true")
-
- expect(page).to have_css("#reply-control.open")
- expect(composer).to have_rich_editor
- end
-
- it "does not auto-open the composer outside embed mode" do
+ it "does not show the docked composer outside embed mode" do
visit("/t/#{no_reply_topic.slug}/#{no_reply_topic.id}")
- expect(page).to have_no_css("#reply-control.open")
- expect(page).to have_no_css("#reply-control.fullscreen")
+ expect(topic_page).to have_no_docked_composer
end
it "does not show floating timeline button" do
@@ -107,42 +98,51 @@ describe "Embed mode" do
expect(topic_page).to have_no_floating_timeline_button
end
+
+ it "hides the standard composer" do
+ visit("/t/#{no_reply_topic.slug}/#{no_reply_topic.id}?embed_mode=true")
+
+ expect(page).to have_no_css("#reply-control.open")
+ end
end
context "with a topic that has replies" do
fab!(:reply) { Fabricate(:post, topic: topic) }
- it "does not auto-open the composer" do
+ it "shows the docked composer" do
visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
- expect(page).to have_no_css("#reply-control.open")
- expect(page).to have_no_css("#reply-control.fullscreen")
+ expect(topic_page).to have_docked_composer
end
- it "opens the composer when clicking reply" do
+ it "focuses the docked composer when clicking reply" do
visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
- topic_page.click_reply_button
+ topic_page.click_embed_reply_button
- expect(page).to have_css("#reply-control.open")
+ expect(page).to have_css(".embed-mode-composer .d-editor-input:focus")
+ end
+
+ it "submits a reply through the docked composer" do
+ user.user_option.update!(composition_mode: UserOption.composition_mode_types[:markdown])
+ visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
+
+ expect(topic_page).to have_docked_composer
+
+ find(".embed-mode-composer .d-editor-input").fill_in(with: "Hello from the docked composer")
+ find(".embed-mode-composer .docked-composer__submit-btn").click
+
+ expect(page).to have_css(".topic-post", text: "Hello from the docked composer")
end
context "with many replies" do
before { 15.times { Fabricate(:post, topic: topic) } }
- it "shows floating action buttons when footer is not visible" do
+ it "shows floating timeline button 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")
+ expect(topic_page).to have_no_floating_reply_button
end
it "opens the timeline when clicking the floating timeline button" do
@@ -181,11 +181,10 @@ describe "Embed mode" do
fab!(:no_reply_topic, :topic)
fab!(:no_reply_post) { Fabricate(:post, topic: no_reply_topic) }
- it "does not auto-open the composer" do
+ it "does not show the docked composer" do
visit("/t/#{no_reply_topic.slug}/#{no_reply_topic.id}?embed_mode=true")
- expect(page).to have_no_css("#reply-control.open")
- expect(page).to have_no_css("#reply-control.fullscreen")
+ expect(topic_page).to have_no_docked_composer
end
it "shows login label on the embed first-reply footer" do
diff --git a/spec/system/page_objects/pages/topic.rb b/spec/system/page_objects/pages/topic.rb
index cb7b3d0782e..bef95d9ea4e 100644
--- a/spec/system/page_objects/pages/topic.rb
+++ b/spec/system/page_objects/pages/topic.rb
@@ -244,7 +244,6 @@ module PageObjects
def click_floating_reply_button
find(".embed-floating-reply-button").click
- has_expanded_composer?
end
def has_floating_reply_button?
@@ -267,6 +266,19 @@ module PageObjects
has_no_css?(".embed-floating-timeline-button")
end
+ def has_docked_composer?
+ has_css?(".embed-mode-composer .docked-composer")
+ end
+
+ def has_no_docked_composer?
+ has_no_css?(".embed-mode-composer .docked-composer")
+ end
+
+ def click_embed_reply_button
+ within_topic_footer_buttons { find(".create").click }
+ self
+ end
+
def has_expanded_composer?
has_css?("#reply-control.open")
end