FIX: expanding / collapsing own user info panel (#30272)

When viewing your own user profile, we offer the ability to expand / collapse your user info.

By default, the info are collapsed and the button to toggle it only worked once. Meaning you could expand the info but not collapse it back.

This fixes the issue by using `toggleProperty()` instead of directly `set()`-ing a value.

Also added an acceptance test to ensure it doesn't regress.

Was reported in https://meta.discourse.org/t/342254
This commit is contained in:
Régis Hanol 2024-12-13 17:37:57 +01:00 committed by GitHub
parent bdd4392c01
commit 29dad8bbea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 8 deletions

View File

@ -84,7 +84,7 @@ export default class UserController extends Controller.extend(CanCheckEmails) {
ariaLabel: this.collapsedInfo
? "user.sr_expand_profile"
: "user.sr_collapse_profile",
action: this.collapsedInfo ? "expandProfile" : "collapseProfile",
action: "toggleProfile",
};
}
@ -208,13 +208,8 @@ export default class UserController extends Controller.extend(CanCheckEmails) {
}
@action
collapseProfile() {
this.set("forceExpand", false);
}
@action
expandProfile() {
this.set("forceExpand", true);
toggleProfile() {
this.toggleProperty("forceExpand");
}
@action

View File

@ -25,6 +25,21 @@ acceptance("User Profile - Summary", function (needs) {
.exists("top categories");
});
test("Viewing Summary - Expanding / collapsing info", async function (assert) {
await visit("/u/eviltrout/summary");
const collapsed = `button[aria-controls="collapsed-info-panel"][aria-expanded="false"]`;
const expanded = `button[aria-controls="collapsed-info-panel"][aria-expanded="true"]`;
assert.dom(collapsed).exists("info panel is collapsed");
await click(collapsed);
assert.dom(expanded).exists("info panel is expanded");
await click(expanded);
assert.dom(collapsed).exists("info panel is collapsed");
});
test("Top Categories Search", async function (assert) {
await visit("/u/eviltrout/summary");