From 95f80325e52b2dd006c514dd2d18fe627112145d Mon Sep 17 00:00:00 2001 From: Keegan George Date: Wed, 18 Sep 2024 10:36:42 -0700 Subject: [PATCH] DEV: Prevent close of summary from outside clicks (#808) Often it is helpful to have the summary box open while composing a reply to the topic. However, the summary box currently gets closed each time you click outside the box. In this PR we add `closeOnClickOutside: false` attribute to the `DMenu` options for summary box to prevent that from occurring. --- .../topic-map-expanded-after/ai-summary-box.gjs | 1 + test/javascripts/acceptance/topic-summary-test.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-box.gjs b/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-box.gjs index 7bd5b444..97b8322f 100644 --- a/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-box.gjs +++ b/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-box.gjs @@ -196,6 +196,7 @@ export default class AiSummaryBox extends Component { @title={{i18n "summary.buttons.generate"}} @icon="discourse-sparkles" @triggerClass="ai-topic-summarization" + @closeOnClickOutside={{false}} > <:content>
diff --git a/test/javascripts/acceptance/topic-summary-test.js b/test/javascripts/acceptance/topic-summary-test.js index 8a915b95..97e89022 100644 --- a/test/javascripts/acceptance/topic-summary-test.js +++ b/test/javascripts/acceptance/topic-summary-test.js @@ -1,5 +1,5 @@ import { click, visit } from "@ember/test-helpers"; -import { skip } from "qunit"; +import { skip, test } from "qunit"; import topicFixtures from "discourse/tests/fixtures/topic"; import { acceptance, @@ -125,7 +125,7 @@ acceptance("Topic - Summary - Anon", function (needs) { }); }); - skip("displays cached summary immediately", async function (assert) { + test("displays cached summary immediately", async function (assert) { await visit("/t/-/1"); await click(".ai-topic-summarization"); @@ -138,4 +138,11 @@ acceptance("Topic - Summary - Anon", function (needs) { .dom(".ai-summary-box .summarized-on") .exists("summary metadata exists"); }); + + test("clicking outside of summary should not close the summary box", async function (assert) { + await visit("/t/-/1"); + await click(".ai-topic-summarization"); + await click("#main-outlet-wrapper"); + assert.dom(".ai-summary-box").exists(); + }); });