Skip to content
Snippets Groups Projects
Commit 706c782a authored by Younn Olivier's avatar Younn Olivier
Browse files

[FIX] website: correctly remove website systray on replayed action

[1] added a way to detect a replayed action, and returns early the
effect that parses the action's params to ignore them.

This implementation is an error, as the return value of the effect was
not consistent: for a replayed action, it was not returning the cleanup
function that resets the pageDocument, websiteRootInstance and
currentwebsiteId.

This was leading to such behaviour, with enterprise modules:
- Go to the website,
- Click on the top left 'home' button,
- Click on the top left arrow to replay the action,
- Click on the top left 'home' button again,
=> The website systray is still there.

To fix that, the cleanup function is moved to an onWillUnmount hook.

Also, blocking the iframe until its first load event is called in an
onMounted hook, as it is the same as using a useEffect hook with no
dependency and no cleanup function, but it is clearer.

[1]: https://github.com/odoo/odoo/commit/83501e38a338cabd5a064dd0db9f70df08a3aadc

Related to https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2687506

Part-of: odoo/odoo#98352
parent e4d7fbfc
Branches
Tags
No related merge requests found
......@@ -8,7 +8,7 @@ import { WebsiteEditorComponent } from '../../components/editor/editor';
import { WebsiteTranslator } from '../../components/translator/translator';
import {OptimizeSEODialog} from '@website/components/dialog/seo';
const { Component, onWillStart, useRef, useEffect, useState } = owl;
const { Component, onWillStart, onMounted, onWillUnmount, useRef, useEffect, useState } = owl;
class BlockIframe extends Component {
setup() {
......@@ -95,22 +95,22 @@ export class WebsitePreview extends Component {
if (this.props.action.context.params && this.props.action.context.params.with_loader) {
this.websiteService.showLoader({ showTips: true });
}
return () => {
this.websiteService.currentWebsiteId = null;
this.websiteService.websiteRootInstance = undefined;
this.websiteService.pageDocument = null;
};
}, () => [this.props.action.context.params]);
useEffect(() => {
onMounted(() => {
this.websiteService.blockIframe(true, 0, 'load-iframe');
this.iframe.el.addEventListener('load', () => this.websiteService.unblockIframe('load-iframe'), { once: true });
// For a frontend page, it is better to use the
// OdooFrameContentLoaded event to unblock the iframe, as it is
// triggered faster than the load event.
this.iframe.el.addEventListener('OdooFrameContentLoaded', () => this.websiteService.unblockIframe('load-iframe'), { once: true });
}, () => []);
});
onWillUnmount(() => {
this.websiteService.currentWebsiteId = null;
this.websiteService.websiteRootInstance = undefined;
this.websiteService.pageDocument = null;
});
}
get websiteId() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment