From 974903c3d0855c5667623acff016ac46ad4ff00a Mon Sep 17 00:00:00 2001 From: visp-odoo Date: Fri, 16 Feb 2024 10:54:31 +0530 Subject: [PATCH] [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) --- addons/web/static/src/core/dropdown/dropdown.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/core/dropdown/dropdown.js b/addons/web/static/src/core/dropdown/dropdown.js index 9368fce9d61..5d0c90a5734 100644 --- a/addons/web/static/src/core/dropdown/dropdown.js +++ b/addons/web/static/src/core/dropdown/dropdown.js @@ -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; }