From 187f9a94951531e1104f4542336aa3654829d4ed Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Mon, 4 Sep 2023 17:06:41 +0800 Subject: [PATCH] FIX: Replying to OP is a reply to the topic, not the post (#23380) Clicking on the OP's Reply button twice results in the post being a reply to post number 1. This is a fix for that. --- .../discourse/app/controllers/topic.js | 3 ++- .../discourse/tests/acceptance/composer-test.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js index 9d5fd69deb6..76efe82073e 100644 --- a/app/assets/javascripts/discourse/app/controllers/topic.js +++ b/app/assets/javascripts/discourse/app/controllers/topic.js @@ -657,7 +657,8 @@ export default Controller.extend(bufferedProperty("model"), { if ( composerController.get("model.topic.id") === topic.get("id") && - composerController.get("model.action") === Composer.REPLY + composerController.get("model.action") === Composer.REPLY && + post?.get("post_number") !== 1 ) { composerController.set("model.post", post); composerController.set("model.composeState", Composer.OPEN); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js index 22a30cc32b1..3f0920527aa 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js @@ -334,6 +334,22 @@ acceptance("Composer", function (needs) { ); }); + test("Replying to the first post in a topic is a topic reply", async function (assert) { + await visit("/t/internationalization-localization/280"); + + await click("#post_1 .reply.create"); + assert.strictEqual( + query(".reply-details a.topic-link").innerText, + "Internationalization / localization" + ); + + await click("#post_1 .reply.create"); + assert.strictEqual( + query(".reply-details a.topic-link").innerText, + "Internationalization / localization" + ); + }); + test("Can edit a post after starting a reply", async function (assert) { await visit("/t/internationalization-localization/280");