FIX: No JIT when quoting a mention (#12835)

FIX: No JIT when quoting a mention (#12835)

diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js
index 3137291..a50aee0 100644
--- a/app/assets/javascripts/discourse/app/components/composer-editor.js
+++ b/app/assets/javascripts/discourse/app/components/composer-editor.js
@@ -540,6 +540,10 @@ export default Component.extend({
     schedule("afterRender", () => {
       let found = this.warnedGroupMentions || [];
       $preview.find(".mention-group.notify").each((idx, e) => {
+        if (this._isInQuote(e)) {
+          return;
+        }
+
         const $e = $(e);
         let name = $e.data("name");
         if (found.indexOf(name) === -1) {
@@ -860,6 +864,30 @@ export default Component.extend({
     this.send("togglePreview");
   },
 
+  _isInQuote(element) {
+    let parent = element.parentElement;
+    while (parent && !this._isPreviewRoot(parent)) {
+      if (this._isQuote(parent)) {
+        return true;
+      }
+
+      parent = parent.parentElement;
+    }
+
+    return false;
+  },
+
+  _isPreviewRoot(element) {
+    return (
+      element.tagName === "DIV" &&
+      element.classList.contains("d-editor-preview")
+    );
+  },
+
+  _isQuote(element) {
+    return element.tagName === "ASIDE" && element.classList.contains("quote");
+  },
+
   actions: {
     importQuote(toolbarEvent) {
       this.importQuote(toolbarEvent);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
index 5def6ee..99236da 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
@@ -29,6 +29,15 @@ acceptance("Composer", function (needs) {
     server.get("/posts/419", () => {
       return helper.response({ id: 419 });
     });
+    server.get("/u/is_local_username", () => {
+      return helper.response({
+        valid: [],
+        valid_groups: ["staff"],
+        mentionable_groups: [{ name: "staff", user_count: 30 }],
+        cannot_see: [],
+        max_users_notified_per_group_mention: 100,
+      });
+    });
   });
 
   skip("Tests the Composer controls", async function (assert) {
@@ -1007,4 +1016,18 @@ acceptance("Composer", function (needs) {
     await fillIn(".d-editor-input", "[](https://github.com)");
     assert.equal(find(".composer-popup").length, 1);
   });
+
+  test("Shows the 'group_mentioned' notice", async function (assert) {
+    await visit("/t/internationalization-localization/280");
+    await click("#topic-footer-buttons .create");
+
+    await fillIn(".d-editor-input", "[quote]\n@staff\n[/quote]");
+    assert.notOk(
+      exists(".composer-popup"),
+      "Doesn't show the 'group_mentioned' notice in a quote"
+    );
+
+    await fillIn(".d-editor-input", "@staff");
+    assert.ok(exists(".composer-popup"), "Shows the 'group_mentioned' notice");
+  });
 });

GitHub sha: 2c4fd7f7

This commit appears in #12835 which was approved by jjaffeux and ZogStriP. It was merged by AndrewPrigorshnev.