From 5bc522e836d86e48536d9b5bedbf59eb9f85a78b Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Wed, 15 Jan 2025 10:38:08 +1000 Subject: [PATCH] FIX: Double trigger of close user menu (#30732) When clicking the "new features" notification item for admins that navigates to /whats-new, the user notification menu was not closing. This was happening because inside the UserMenu::Menu component, the `routeDidChange` event was firing and calling `closeUserMenu()`, however this is already called inside the `Header` component via `toggleHamburger()`. This is _only_ happening for the "new features" notification item, other items have already been destroyed and they do not get the `routeDidChange` event. No idea why, but this fixes the issue in a global way. --- app/assets/javascripts/discourse/app/components/header.gjs | 4 ++-- .../discourse/app/components/header/user-menu-wrapper.gjs | 4 ++-- config/locales/client.en.yml | 2 +- plugins/chat/spec/system/bookmark_message_spec.rb | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/header.gjs b/app/assets/javascripts/discourse/app/components/header.gjs index 32ac3e3ac26..258c85b5fc3 100644 --- a/app/assets/javascripts/discourse/app/components/header.gjs +++ b/app/assets/javascripts/discourse/app/components/header.gjs @@ -205,8 +205,8 @@ export default class GlimmerHeader extends Component { } @action - toggleUserMenu() { - this.header.userVisible = !this.header.userVisible; + toggleUserMenu(value) { + this.header.userVisible = value ?? !this.header.userVisible; this.toggleBodyScrolling(this.header.userVisible); this.args.animateMenu(); } diff --git a/app/assets/javascripts/discourse/app/components/header/user-menu-wrapper.gjs b/app/assets/javascripts/discourse/app/components/header/user-menu-wrapper.gjs index 4f2670462c5..d85c39a81fd 100644 --- a/app/assets/javascripts/discourse/app/components/header/user-menu-wrapper.gjs +++ b/app/assets/javascripts/discourse/app/components/header/user-menu-wrapper.gjs @@ -1,5 +1,5 @@ import Component from "@glimmer/component"; -import { hash } from "@ember/helper"; +import { fn, hash } from "@ember/helper"; import { action } from "@ember/object"; import { isTesting } from "discourse/lib/environment"; import discourseLater from "discourse/lib/later"; @@ -53,7 +53,7 @@ export default class UserMenuWrapper extends Component { }} ...attributes > - + } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index fe059fe4929..893b9b60e44 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2941,7 +2941,7 @@ en: membership_request_consolidated: "new membership requests" reaction: "new reaction" votes_released: "Vote was released" - new_features: "new Discourse features have been released!" + new_features: "New Discourse features have been released!" admin_problems: "new advice on your site dashboard" upload_selector: diff --git a/plugins/chat/spec/system/bookmark_message_spec.rb b/plugins/chat/spec/system/bookmark_message_spec.rb index 365a4c11755..235acc3a6b9 100644 --- a/plugins/chat/spec/system/bookmark_message_spec.rb +++ b/plugins/chat/spec/system/bookmark_message_spec.rb @@ -73,6 +73,9 @@ RSpec.describe "Bookmark message", type: :system do expect(channel_page).to have_bookmarked_message(message_1) + user_menu.open + user_menu.click_bookmarks_tab + user_menu.click_bookmark(bookmark_2) expect(channel_page).to have_bookmarked_message(message_2)