From dd9d6d0fac6ffc667b2e897434793db45ea201cc Mon Sep 17 00:00:00 2001 From: Pierre Paridans Date: Fri, 20 Sep 2019 14:11:28 +0000 Subject: [FIX] web: crash when resizing on tablet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When having a long systray (icons from different apps, mode debug, multi-company...) the resize of the window can trigger a crash for apps that have not too much top-level menus (e.g. Contacts). This also happens when loading those apps. Steps to reproduce (on an iPad, portrait): * use a Runbot with all modules installed (12.0+) * activate "debug mode" * ensure that the menu/systray bar is quite full * open the "Contacts" app => traceback with a "cannot call getBoundingClientRect of undefined" error The reason is that the resize's callback iterate over the systray/menu items to find which one should be folded behind a "more" ("+") menu item. Sadly in some cases (combination of screen width, systray size, app's number of menus) it can lead to a traceback. This commit ensures that when looping for menu items, we don't try to reach an non-existing item. closes odoo/odoo#37329 X-original-commit: odoo/odoo@d7bae0329990171710acf2d9c0d4d9579cba2c0e Signed-off-by: Adrien Dieudonné (adr) Co-authored-by: Romeo Fragomeli --- addons/web/static/src/js/core/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/core/dom.js b/addons/web/static/src/js/core/dom.js index f260478da1e..d2fdb41fefc 100644 --- a/addons/web/static/src/js/core/dom.js +++ b/addons/web/static/src/js/core/dom.js @@ -537,7 +537,7 @@ var dom = { menuItemsWidth += computeFloatOuterWidthWithMargins($extraItemsToggle[0]); do { menuItemsWidth -= computeFloatOuterWidthWithMargins($items.eq(--nbItems)[0]); - } while (!(maxWidth - menuItemsWidth >= -0.001)); + } while (!(maxWidth - menuItemsWidth >= -0.001) && (nbItems > 0)); var $extraItems = $items.slice(nbItems).detach(); $extraItems.removeClass('nav-item'); -- cgit v1.2.3