FIX: Do not show nested user cards. (#6621)

FIX: Do not show nested user cards. (#6621)

From f2c227432cdf7923ff88247dbf65c036d21250f7 Mon Sep 17 00:00:00 2001
From: Bianca Nenciu <nbianca@users.noreply.github.com>
Date: Mon, 19 Nov 2018 11:01:22 +0200
Subject: [PATCH] FIX: Do not show nested user cards. (#6621)


diff --git a/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6 b/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6
index 2313eae..d757fad 100644
--- a/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6
+++ b/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6
@@ -25,8 +25,9 @@ export default Ember.Mixin.create({
 
     username = Ember.Handlebars.Utils.escapeExpression(username.toString());
 
-    // Don't show on mobile
-    if (this.site.mobileView) {
+    // Don't show on mobile or nested
+    if (this.site.mobileView || $target.parents(".card-content").length) {
+      this._close();
       DiscourseURL.routeTo($target.attr("href"));
       return false;
     }
diff --git a/test/javascripts/acceptance/user-card-test.js.es6 b/test/javascripts/acceptance/user-card-test.js.es6
index eace2a8..30d163b 100644
--- a/test/javascripts/acceptance/user-card-test.js.es6
+++ b/test/javascripts/acceptance/user-card-test.js.es6
@@ -1,4 +1,5 @@
 import { acceptance } from "helpers/qunit-helpers";
+import DiscourseURL from "discourse/lib/url";
 
 acceptance("User Card");
 
@@ -8,4 +9,8 @@ QUnit.test("user card", async assert => {
 
   await click("a[data-user-card=eviltrout]:first");
   assert.ok(visible("#user-card"), "card should appear");
+
+  sandbox.stub(DiscourseURL, "routeTo");
+  await click(".card-content a.mention");
+  assert.ok(DiscourseURL.routeTo.calledWith("/u/eviltrout"));
 });
diff --git a/test/javascripts/fixtures/user_fixtures.js.es6 b/test/javascripts/fixtures/user_fixtures.js.es6
index 756c6d2..b639c5c 100644
--- a/test/javascripts/fixtures/user_fixtures.js.es6
+++ b/test/javascripts/fixtures/user_fixtures.js.es6
@@ -124,9 +124,9 @@ export default {
       last_posted_at: "2015-05-07T15:23:35.074Z",
       last_seen_at: "2015-05-13T14:34:23.188Z",
       bio_raw:
-        'Co-founder of Discourse. Previously, I created <a href="http://forumwarz.com">Forumwarz</a>. <a href="https://twitter.com/eviltrout">Follow me on Twitter</a>.',
+        'Co-founder of Discourse. Previously, I created <a href="http://forumwarz.com">Forumwarz</a>. <a href="https://twitter.com/eviltrout">Follow me on Twitter</a>. I am @eviltrout.',
       bio_cooked:
-        '<p>Co-founder of Discourse. Previously, I created <a href="http://forumwarz.com">Forumwarz</a>. <a href="https://twitter.com/eviltrout">Follow me on Twitter</a>.</p>',
+        '<p>Co-founder of Discourse. Previously, I created <a href="http://forumwarz.com">Forumwarz</a>. <a href="https://twitter.com/eviltrout">Follow me on Twitter</a>. I am <a class="mention" href="/u/eviltrout">@eviltrout</a>.</p>',
       created_at: "2013-02-03T15:19:22.704Z",
       website: "http://eviltrout.com",
       location: "Toronto",
@@ -150,7 +150,7 @@ export default {
       can_send_private_messages: true,
       can_send_private_message_to_user: false,
       bio_excerpt:
-        'Co-founder of Discourse. Previously, I created <a href="http://forumwarz.com">Forumwarz</a>. <a href="https://twitter.com/eviltrout">Follow me on Twitter</a>.',
+        '<p>Co-founder of Discourse. Previously, I created <a href="http://forumwarz.com">Forumwarz</a>. <a href="https://twitter.com/eviltrout">Follow me on Twitter</a>. I am <a class="mention" href="/u/eviltrout">@eviltrout</a>.</p>',
       trust_level: 4,
       moderator: true,
       admin: true,

GitHub

1 Like