From 4421820354c4d20c5a9c1a85e12a27c137260828 Mon Sep 17 00:00:00 2001 From: jbrw Date: Fri, 25 Sep 2020 15:01:57 -0400 Subject: [PATCH] =?UTF-8?q?FIX:=20don=E2=80=99t=20include=20category=20in?= =?UTF-8?q?=20quote=20topic=20title,=20if=20present?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../discourse/app/components/quote-button.js | 6 ++++++ test/javascripts/acceptance/topic-test.js | 17 +++++++++++++++++ test/javascripts/fixtures/topic.js | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/components/quote-button.js b/app/assets/javascripts/discourse/app/components/quote-button.js index 6665453a3a3..e0b2bae75d7 100644 --- a/app/assets/javascripts/discourse/app/components/quote-button.js +++ b/app/assets/javascripts/discourse/app/components/quote-button.js @@ -19,6 +19,12 @@ function getQuoteTitle(element) { if (!titleEl) { return; } + + const titleLink = titleEl.querySelector("a:not(.back)"); + if (titleLink) { + return titleLink.textContent.trim(); + } + return titleEl.textContent.trim().replace(/:$/, ""); } diff --git a/test/javascripts/acceptance/topic-test.js b/test/javascripts/acceptance/topic-test.js index 8e673168aa5..d40bdb26deb 100644 --- a/test/javascripts/acceptance/topic-test.js +++ b/test/javascripts/acceptance/topic-test.js @@ -337,6 +337,23 @@ QUnit.test("Quoting a quote keeps the original poster name", async (assert) => { ); }); +QUnit.test( + "Quoting a quote of a different topic keeps the original topic title", + async (assert) => { + await visit("/t/internationalization-localization/280"); + selectText("#post_9 blockquote"); + await click(".quote-button .insert-quote"); + + assert.ok( + find(".d-editor-input") + .val() + .indexOf( + 'quote="A new topic with a link to another topic, post:3, topic:62"' + ) !== -1 + ); + } +); + QUnit.test( "Quoting a quote with the Reply button keeps the original poster name", async (assert) => { diff --git a/test/javascripts/fixtures/topic.js b/test/javascripts/fixtures/topic.js index beddf91d948..0eaa20ad1d9 100644 --- a/test/javascripts/fixtures/topic.js +++ b/test/javascripts/fixtures/topic.js @@ -851,7 +851,7 @@ export default { uploaded_avatar_id: 5253, created_at: "2013-02-07T14:14:12.666Z", cooked: - '

\n\n

Yeah, that\'s why I\'ve always been a friend of message_error_nametooshort placeholders, until I asked the SO question linked above. The accepted answer makes a good argument against those placeholders: you want translations to break even on small changes in the English original because the translations will probably need to reflect the change, too. Maybe that\'s not the case right now as new stuff is being checked in pretty much every couple of hours, but in the long run, it\'ll be overwhelmingly true.

', + '\n

repost after a reload thank you!

', post_number: 9, post_type: 1, updated_at: "2013-02-07T14:18:09.569Z",