Files
odoo_source/addons/website/static
Romain Derie f94c1ea65f [FIX] website: prevent traceback because megamenu toggle does not exist
Commit [1] introduced a method to restore the mega menu state (closed)
so it's not saved open when saving the website builder edition.
That method is `_restoreMegaMenus()`.

It was then moved with commit [2], where it was called in `destroy`
where it was actually making the code crash because once you reach
`destroy`, the website content (the iframe) has already been reloaded
(and thus removed / recreated).
It's done through `reloadIframe()`.

So, depending of your network speed and the server response time, if the
page is served before reaching the mega menu restoration, it will crash.

Restoring the mega menu in the (wysiwig) destroy doesn't seems to do
anything as the page is already saved when reaching `destroy`.

Step to reproduce:
- Have a high latency, like 500ms (you can create a profile in chrome
  debug tool in network tab)
- Create a mega menu on the website
- Enter edit mode
- Directly save or discard
-> Traceback, the jQuery toggle elements (`.o_mega_menu_toggle`) are not
   in the DOM anymore, since the iframe got reloaded. Those elements
   thus don't have a reference to `$` anymore, ultimately making this
   line crash:

```js
const $toggle = toggle.ownerDocument.defaultView.$(toggle);
```

[1]: https://github.com/odoo/odoo/commit/1345702258adbfbee0d780dc22e552395e6d1df7
[2]: https://github.com/odoo/odoo/commit/d7245d2abf528d093226c80e40975e63d61e8997

opw-3483837
opw-3478642

closes odoo/odoo#138538

X-original-commit: caeb92bfb624c9c30ec9f9e3c2b1dd385e9b089b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-10-12 17:20:47 +00:00
..