[FIX] website: not fail in Firefox when leaving/entering website app

Since [1], navigating from the website application to another one
raises an error when using Firefox.

This commit avoids looking at the URL if the iframe is not available.

It seems that in Firefox the `pagehide` event is triggered after the
iframe is released.

Steps to reproduce:
- Use Firefox.
- Go to the Website app.
- Go to Discuss.

=> An error popup was displayed.

[1]: https://github.com/odoo/odoo/commit/eacfab230b8b6d676f378ad74a402849af83dcbb

task-3302981
opw-3349388
opw-3357461
opw-3357511

closes odoo/odoo#124940

X-original-commit: 57c3ab3058d4e2eee581f5c35a7a9e1b9ac83593
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
This commit is contained in:
Benoit Socias
2023-06-14 09:39:16 +02:00
committed by Romain Derie
parent 364e13da96
commit e6dd94aa21
@@ -475,7 +475,7 @@ export class WebsitePreview extends Component {
}
}
_onPageHide() {
this.lastHiddenPageURL = this.iframe.el.contentWindow.location.href;
this.lastHiddenPageURL = this.iframe.el && this.iframe.el.contentWindow.location.href;
// Normally, at this point, the websiteRootInstance is already set to
// `undefined`, as we want to do that as early as possible to prevent
// the editor to be in an unstable state. But some events not managed