[IMP] web: convert condition into function

With this commit, overriding the `onWindowClick` function from `dropdown.js`
becomes much simpler. Previously, it necessitated overriding the entire function,
but now it can be done with minimal effort by just overriding this specific part.

task-3717014

closes odoo/odoo#155326

X-original-commit: edf3c7f5c566f530bed2f243a6f78fcf7d1196d2
Related: odoo/enterprise#57471
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
This commit is contained in:
visp-odoo
2024-02-27 14:41:47 +00:00
parent 96debc0764
commit 974903c3d0
@@ -307,6 +307,13 @@ export class Dropdown extends Component {
}
}
/**
* Return true if both active element are same.
*/
isInActiveElement() {
return this.ui.activeElement === this.myActiveEl;
}
/**
* Used to close ourself on outside click.
*
@@ -318,7 +325,7 @@ export class Dropdown extends Component {
return;
}
// Return if it's a different ui active element
if (this.ui.activeElement !== this.myActiveEl) {
if (!this.isInActiveElement()) {
return;
}