FIX: close user card after clicking Message button

This was primarily an issue on mobile, where after clicking the "Messsage" button in the user card, the composer would load behind the user card overlay.
This commit is contained in:
Penar Musaraj 2019-08-30 13:40:12 -04:00
parent 310a8ac242
commit 4d6eacac5c
4 changed files with 26 additions and 2 deletions

View File

@ -184,6 +184,14 @@ export default Ember.Component.extend(
this._close();
},
composePM(user, post) {
this._close();
Ember.getOwner(this)
.lookup("router:main")
.send("composePrivateMessage", user, post);
},
cancelFilter() {
const postStream = this.postStream;
postStream.cancelFilter();

View File

@ -72,7 +72,7 @@
<li class='compose-pm'>
{{d-button
class="btn-primary"
action=(route-action "composePrivateMessage" user post)
action=(action "composePM" user post)
icon="envelope"
label="user.private_message"}}
</li>

View File

@ -1,7 +1,7 @@
import { acceptance } from "helpers/qunit-helpers";
import DiscourseURL from "discourse/lib/url";
acceptance("User Card");
acceptance("User Card", { loggedIn: true });
QUnit.test("user card", async assert => {
await visit("/t/internationalization-localization/280");
@ -16,4 +16,13 @@ QUnit.test("user card", async assert => {
DiscourseURL.routeTo.calledWith("/u/eviltrout"),
"it should navigate to the user profile"
);
await click("a[data-user-card=charlie]:first");
assert.ok(visible("#user-card"), "card should appear");
await click(".card-content .compose-pm button");
assert.ok(
invisible("#user-card"),
"user card dismissed after hitting Message button"
);
});

View File

@ -2057,6 +2057,13 @@ export default {
avatar_template: "/images/avatar.png",
post_count: 4
},
{
id: 5,
username: "charlie",
uploaded_avatar_id: 5275,
avatar_template: "/images/avatar.png",
post_count: 1
},
{
id: 3704,
username: "mojzis",