Skip to content
Snippets Groups Projects
Commit 442f74ff authored by Pierre Paridans's avatar Pierre Paridans Committed by fw-bot
Browse files

[FIX] web: crash when resizing on tablet


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#37245

X-original-commit: d7bae032
Signed-off-by: default avatarPierre Paridans <pparidans@users.noreply.github.com>
Co-authored-by: default avatarRomeo Fragomeli <rfr@odoo.com>
parent 7bea9126
No related branches found
No related tags found
No related merge requests found
......@@ -540,7 +540,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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment