mirror of
https://github.com/discourse/discourse.git
synced 2025-02-05 19:11:13 +00:00
FIX: do not auto close on empty identifiers (#27001)
Prior to this fix all menus with empty identifier or groupIdentifier would be considered to be part of the same identifiers/groupIdentifiers and would auto close any existing d-menu with no identifier/groupIdentifier when opened.
This commit is contained in:
parent
742a3b138d
commit
f840f37a54
@ -311,6 +311,22 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
|
||||
assert.dom(".fk-d-menu__content.second").exists();
|
||||
});
|
||||
|
||||
test("empty @identifier/@groupIdentifier", async function (assert) {
|
||||
await render(
|
||||
hbs`<DMenu @inline={{true}} @class="first">1</DMenu><DMenu @inline={{true}} @class="second">2</DMenu>`
|
||||
);
|
||||
|
||||
await click(".first.fk-d-menu__trigger");
|
||||
|
||||
assert.dom(".fk-d-menu__content.first").exists();
|
||||
assert.dom(".fk-d-menu__content.second").doesNotExist();
|
||||
|
||||
await click(".second.fk-d-menu__trigger");
|
||||
|
||||
assert.dom(".fk-d-menu__content.first").exists("it doesn’t autoclose");
|
||||
assert.dom(".fk-d-menu__content.second").exists();
|
||||
});
|
||||
|
||||
test("@class", async function (assert) {
|
||||
await render(hbs`<DMenu @inline={{true}} @class="first">1</DMenu>`);
|
||||
|
||||
|
@ -52,9 +52,12 @@ export default class Menu extends Service {
|
||||
if (instance.options.identifier || instance.options.groupIdentifier) {
|
||||
for (const registeredMenu of this.registeredMenus) {
|
||||
if (
|
||||
(registeredMenu.options.identifier === instance.options.identifier ||
|
||||
registeredMenu.options.groupIdentifier ===
|
||||
instance.options.groupIdentifier) &&
|
||||
((instance.options.identifier &&
|
||||
registeredMenu.options.identifier ===
|
||||
instance.options.identifier) ||
|
||||
(instance.options.groupIdentifier &&
|
||||
registeredMenu.options.groupIdentifier ===
|
||||
instance.options.groupIdentifier)) &&
|
||||
registeredMenu !== instance
|
||||
) {
|
||||
await this.close(registeredMenu);
|
||||
|
Loading…
x
Reference in New Issue
Block a user