UX: Close the revamped user menu when opening modals (#18148)

When opening the DnD modal and the User Status modal, user menu remained open, this fixes it.
This commit is contained in:
David Taylor 2022-09-01 12:22:41 +01:00 committed by GitHub
parent 5bc858c676
commit c782125985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 3 deletions

View File

@ -6,7 +6,7 @@
class="quick-access-panel"
tabindex="-1"
aria-labelledby={{concat "user-menu-button-" this.currentTabId}}>
{{component this.currentPanelComponent}}
{{component this.currentPanelComponent closeUserMenu=@closeUserMenu}}
</div>
<div class="menu-tabs-container" role="tablist" aria-orientation="vertical" aria-label={{i18n "user_menu.sr_menu_tabs"}}>
<div class="top-tabs tabs-list">

View File

@ -48,12 +48,14 @@ export default class UserMenuProfileTabContent extends Component {
});
} else {
this.saving = false;
this.args.closeUserMenu();
showModal("do-not-disturb");
}
}
@action
setUserStatusClick() {
this.args.closeUserMenu();
showModal("user-status", {
title: "user_status.set_custom_status",
modalClass: "user-status",

View File

@ -407,14 +407,21 @@ createWidget("revamped-user-menu-wrapper", {
new RenderGlimmer(
this,
"div.widget-component-connector",
hbs`<UserMenu::Menu />`
hbs`<UserMenu::Menu @closeUserMenu={{@data.closeUserMenu}} />`,
{
closeUserMenu: this.closeUserMenu.bind(this),
}
),
];
},
clickOutside() {
closeUserMenu() {
this.sendWidgetAction("toggleUserMenu");
},
clickOutside() {
this.closeUserMenu();
},
});
export default createWidget("header", {

View File

@ -209,4 +209,15 @@ acceptance("Do not disturb - new user menu", function (needs) {
"the Do Not Disturb button has the toggle-off icon"
);
});
test("user menu gets closed when the DnD modal is opened", async function (assert) {
this.siteSettings.enable_user_status = true;
await visit("/");
await click(".header-dropdown-toggle.current-user");
await click("#user-menu-button-profile");
await click("#quick-access-profile .do-not-disturb .btn");
assert.notOk(exists(".user-menu"));
});
});

View File

@ -423,4 +423,15 @@ acceptance("User Status - new user menu", function (needs) {
"shows user status emoji on the user avatar in the header"
);
});
test("user menu gets closed when the user status modal is opened", async function (assert) {
this.siteSettings.enable_user_status = true;
await visit("/");
await click(".header-dropdown-toggle.current-user");
await click("#user-menu-button-profile");
await click(".set-user-status button");
assert.notOk(exists(".user-menu"));
});
});