[REV] web: do not close dropdowns on active el change

This is actually not what we want. It changes the behavior of
the favorite menu: when the user deletes an item, a confirm dialog
opens, but we want the dropdown to remain visible.

Part-of: odoo/odoo#73311
This commit is contained in:
Aaron Bohy
2021-09-07 10:04:32 +00:00
parent 659e7ca975
commit 6cfe05ae4b
2 changed files with 0 additions and 72 deletions
@@ -48,12 +48,6 @@ export class Dropdown extends Component {
// Set up UI active element related behavior ---------------------------
this.ui = useService("ui");
useBus(this.ui.bus, "active-element-changed", (activeElement) => {
if (activeElement !== this.myActiveEl && this.state.open) {
// Close when UI active element changes to something different
this.close();
}
});
useEffect(
() => {
Promise.resolve().then(() => {
@@ -146,32 +146,6 @@ QUnit.module("Components", ({ beforeEach }) => {
assert.containsNone(parent.el, "ul.o_dropdown_menu");
});
QUnit.test("close on activeElement change", async (assert) => {
class Parent extends owl.Component {
setup() {
this.dc = mainComponentsRegistry.get("DialogContainer");
}
}
Parent.template = owl.tags.xml`
<div>
<Dropdown />
<t t-component="dc.Component" t-props="dc.props" />
</div>
`;
class CustomDialog extends Dialog {}
CustomDialog.title = "Dropdown Killer";
serviceRegistry.add("dialog", dialogService);
env = await makeTestEnv();
parent = await mount(Parent, { env, target });
await click(parent.el, "button.o_dropdown_toggler");
await nextTick(); // await that the dropdown sets its active element
assert.containsOnce(parent.el, "ul.o_dropdown_menu");
env.services.dialog.add(CustomDialog);
await nextTick(); // await that the dropdown starts to close
await nextTick(); // await that the dropdown is closed
assert.containsNone(parent.el, "ul.o_dropdown_menu");
});
QUnit.test("close on item selection", async (assert) => {
class Parent extends owl.Component {}
Parent.template = owl.tags.xml`
@@ -256,46 +230,6 @@ QUnit.module("Components", ({ beforeEach }) => {
assert.containsNone(parent.el, "ul.o_dropdown_menu");
});
QUnit.test("multi-level dropdown: close on activeElement change", async (assert) => {
patchWithCleanup(Dropdown.prototype, {
close() {
assert.step("closed");
this._super();
},
});
class Parent extends owl.Component {
setup() {
this.dc = mainComponentsRegistry.get("DialogContainer");
}
}
Parent.template = owl.tags.xml`
<div>
<Dropdown>
<Dropdown>
<Dropdown/>
</Dropdown>
</Dropdown>
<t t-component="dc.Component" t-props="dc.props" />
</div>
`;
class CustomDialog extends Dialog {}
CustomDialog.title = "Dropdown Killer";
serviceRegistry.add("dialog", dialogService);
env = await makeTestEnv();
parent = await mount(Parent, { env, target });
await click(parent.el, "button.o_dropdown_toggler:last-child");
await click(parent.el, "button.o_dropdown_toggler:last-child");
await click(parent.el, "button.o_dropdown_toggler:last-child");
assert.containsN(parent.el, "ul.o_dropdown_menu", 3);
await nextTick(); // await that the dropdowns set their active elements
env.services.dialog.add(CustomDialog);
assert.verifySteps([]);
await nextTick(); // await that the dropdowns start to close
await nextTick(); // await that the dropdowns are closed
assert.containsNone(parent.el, "ul.o_dropdown_menu");
assert.verifySteps(["closed", "closed", "closed"]);
});
QUnit.test("multi-level dropdown: close on item selection", async (assert) => {
class Parent extends owl.Component {}
Parent.template = owl.tags.xml`