Skip to content

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

FIX: resets quote state when reseting text selection (#33463)

Joffrey JAFFEUX9cd271ae60f8
diff --git a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs b/app/assets/javascripts/discourse/app/components/post-text-selection.gjs
index e29ef7b115a..d1f69d6806b 100644
--- a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs
+++ b/app/assets/javascripts/discourse/app/components/post-text-selection.gjs
@@ -201,6 +201,7 @@ export default class PostTextSelection extends Component {
@bind
async hideToolbar() {
+ this.args.quoteState.clear();
await this.menuInstance?.close();
await this.menuInstance?.destroy();
}
diff --git a/spec/system/post_selection_copy_quote_spec.rb b/spec/system/post_selection_copy_quote_spec.rb
index 111eeb0f8a6..b830eede7fd 100644
--- a/spec/system/post_selection_copy_quote_spec.rb
+++ b/spec/system/post_selection_copy_quote_spec.rb
@@ -2,6 +2,7 @@
describe "Post selection | Copy quote", type: :system do
let(:topic_page) { PageObjects::Pages::Topic.new }
+ let(:composer) { PageObjects::Components::Composer.new }
let(:cdp) { PageObjects::CDP.new }
fab!(:topic)
@@ -32,6 +33,18 @@ describe "Post selection | Copy quote", type: :system do
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
expect(page).not_to have_css(topic_page.copy_quote_button_selector)
end
+
+ it "resets the quote state when the toolbar is hidden" do
+ topic_page.visit_topic(topic)
+ select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
+
+ expect(page).to have_css(topic_page.copy_quote_button_selector)
+
+ select_text_range(".topic-map__stat-label", 0, 1) # select non cooked content
+ topic_page.click_reply_button
+
+ expect(composer).to have_value("")
+ end
end
context "when anon" do