From e07bda1d4d7db461385ecd0397d14ae9ce9f6804 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 22 Jun 2021 11:36:17 +0000 Subject: [PATCH] [FIX] web: actions in target="new" should not update title Before this commit, all actions, even those executed in target "new" (i.e. in dialogs) updated the document's title. Actions in dialog should not do that. closes odoo/odoo#72526 Signed-off-by: Lucas Perais (lpe) --- .../web/static/src/legacy/action_adapters.js | 2 +- .../tests/webclient/actions/target_tests.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/action_adapters.js b/addons/web/static/src/legacy/action_adapters.js index b841ede875d..e7a1925abdb 100644 --- a/addons/web/static/src/legacy/action_adapters.js +++ b/addons/web/static/src/legacy/action_adapters.js @@ -29,13 +29,13 @@ class ActionAdapter extends ComponentAdapter { let originalUpdateControlPanel; useEffect( () => { - this.title.setParts({ action: this.widget.getTitle() }); const query = this.widget.getState(); Object.assign(query, this.tempQuery); this.tempQuery = null; this.__widget = this.widget; if (!this.wowlEnv.inDialog) { this.pushState(query); + this.title.setParts({ action: this.widget.getTitle() }); } this.wowlEnv.bus.on("ACTION_MANAGER:UPDATE", this, () => { this.env.bus.trigger("close_dialogs"); diff --git a/addons/web/static/tests/webclient/actions/target_tests.js b/addons/web/static/tests/webclient/actions/target_tests.js index efe14fb0528..78aa943518e 100644 --- a/addons/web/static/tests/webclient/actions/target_tests.js +++ b/addons/web/static/tests/webclient/actions/target_tests.js @@ -3,6 +3,7 @@ import testUtils from "web.test_utils"; import core from "web.core"; import AbstractAction from "web.AbstractAction"; +import { registry } from "@web/core/registry"; import { legacyExtraNextTick } from "../../helpers/utils"; import { createWebClient, doAction, getActionManagerServerData } from "./../helpers"; @@ -297,6 +298,30 @@ QUnit.module("ActionManager", (hooks) => { } ); + QUnit.test('actions in target="new" do not update page title', async function (assert) { + const mockedTitleService = { + start() { + return { + setParts({ action }) { + if (action) { + assert.step(action); + } + }, + }; + }, + }; + registry.category("services").add("title", mockedTitleService); + const webClient = await createWebClient({ serverData }); + + // sanity check: execute an action in target="current" + await doAction(webClient, 1); + assert.verifySteps(["Partners Action 1"]); + + // execute an action in target="new" + await doAction(webClient, 5); + assert.verifySteps([]); + }); + QUnit.module('Actions in target="inline"'); QUnit.test( 'form views for actions in target="inline" open in edit mode',