[FIX] web: fix searchbar menu position

Before this commit, the searchbar menu was misplaced after opening the advanced search dialog.
After this commit, the searchbar menu is always at the correct position.

Task-id: 3673493
X-original-commit: 19d40f48fb98b28b7fd49b79581ac0ac5fcecc87
Part-of: odoo/odoo#149655
This commit is contained in:
Michael (mcm)
2024-01-19 19:10:53 +00:00
parent 6628d2b4e7
commit 86d00f1053
2 changed files with 32 additions and 0 deletions
@@ -167,6 +167,8 @@ export class Dropdown extends Component {
(isOpen) => {
if (isOpen) {
this.props.onOpened();
} else {
this.position.unlock();
}
},
() => [this.state.open]
@@ -268,6 +268,36 @@ QUnit.module("Components", ({ beforeEach }) => {
assert.strictEqual(menuBox3.top - menuBox1.top, 100);
});
QUnit.test("unlock position after close", async (assert) => {
class Parent extends Component {
static template = xml`
<div style="margin-left: 200px;">
<Dropdown holdOnHover="true" position="'bottom-end'">
</Dropdown>
</div>
`;
static components = { Dropdown };
}
env = await makeTestEnv();
await mount(Parent, target, { env });
assert.containsNone(target, ".dropdown-menu");
await click(target, "button.dropdown-toggle");
assert.containsOnce(target, ".dropdown-menu");
const menuBox1 = target.querySelector(".dropdown-menu").getBoundingClientRect();
// Pointer enter the dropdown menu to lock the menu
await mouseEnter(target, ".dropdown-menu");
// close the menu
await click(target);
assert.containsNone(target, ".dropdown-menu");
// and reopen it
await click(target, "button.dropdown-toggle");
assert.containsOnce(target, ".dropdown-menu");
const menuBox2 = target.querySelector(".dropdown-menu").getBoundingClientRect();
assert.strictEqual(menuBox2.left - menuBox1.left, 0);
});
QUnit.test("payload received on item selection", async (assert) => {
class Parent extends Component {
onItemSelected(value) {