[FIX] website: adapt browser URL on "edit translations" mode
Steps to reproduce: - Go to a website page > Add a 'Form' block. - Go to the page (in 'edit_translations' mode) > Reload the page > The form won't be pre-filled with default values. [1] The page reloading with `?edit_translations=1` leads to a misleading situation where the form block is handled as on 'edit_translations' mode (see: `data-edit_translations="1"` on the DOM) hence the behaviour in [1]. The goal of this commit is to prevent this inconsistency by simply adapting the browser URL once "edit_translations" mode is activated. closes odoo/odoo#124889 X-original-commit: 8c7d096a09fe23ac7ef9b7bf54123592c52122dd Signed-off-by: Colin Louis (loco) <loco@odoo.com>
This commit is contained in:
@@ -119,9 +119,7 @@ export class WebsiteTranslator extends WebsiteEditorComponent {
|
||||
this.websiteContext.translation = false;
|
||||
} else {
|
||||
this.state.showWysiwyg = true;
|
||||
const url = new URL(this.websiteService.contentWindow.location.href);
|
||||
url.searchParams.delete('edit_translations');
|
||||
this.websiteService.contentWindow.history.replaceState(this.websiteService.contentWindow.history.state, null, url);
|
||||
this.deleteQueryParam("edit_translations", this.websiteService.contentWindow, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,4 +343,13 @@ export class WebsiteTranslator extends WebsiteEditorComponent {
|
||||
_onSave(ev) {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
deleteQueryParam(param, target = window, adaptBrowserUrl = false) {
|
||||
const url = new URL(target.location.href);
|
||||
url.searchParams.delete(param);
|
||||
target.history.replaceState(target.history.state, null, url);
|
||||
if (adaptBrowserUrl) {
|
||||
this.deleteQueryParam(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user