From 29dad8bbea5797fbf108f0a4e49738beb9bc9739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 13 Dec 2024 17:37:57 +0100 Subject: [PATCH] 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 --- .../javascripts/discourse/app/controllers/user.js | 11 +++-------- .../tests/acceptance/user-profile-summary-test.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/user.js b/app/assets/javascripts/discourse/app/controllers/user.js index eed95755ed9..224c1d3d4c8 100644 --- a/app/assets/javascripts/discourse/app/controllers/user.js +++ b/app/assets/javascripts/discourse/app/controllers/user.js @@ -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 diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js index e924d9418f1..3f659a55352 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js @@ -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");