diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index b2048498b49..a4e4a4205e9 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -538,7 +538,7 @@ function makeActionManager(env) { } onHistoryBack() { const previousController = controllerStack[controllerStack.length - 2]; - if (previousController && !dialogCloseProm) { + if (previousController && !dialog.remove) { restore(previousController.jsId); } else { _executeCloseAction(); diff --git a/addons/web/static/tests/webclient/actions/close_action_tests.js b/addons/web/static/tests/webclient/actions/close_action_tests.js index 036bb6a3061..6e4b0540117 100644 --- a/addons/web/static/tests/webclient/actions/close_action_tests.js +++ b/addons/web/static/tests/webclient/actions/close_action_tests.js @@ -108,6 +108,32 @@ QUnit.module("ActionManager", (hooks) => { assert.containsNone(webClient.el, ".modal"); }); + QUnit.test("history back called within on_close", async function (assert) { + assert.expect(7); + const webClient = await createWebClient({ serverData }); + + await doAction(webClient, 1); + assert.containsOnce(webClient, ".o_kanban_view"); + await doAction(webClient, 3); + assert.containsOnce(webClient, ".o_list_view"); + + function onClose() { + const ev = new Event("history-back", { bubbles: true, cancelable: true }); + webClient.el.querySelector(".o_view_controller").dispatchEvent(ev); + assert.step("on_close"); + } + // open a new dialog form + await doAction(webClient, 5, { onClose }); + + await click(webClient.el, ".modal-header button.close"); + await nextTick(); + await legacyExtraNextTick(); + assert.containsNone(webClient, ".modal"); + assert.containsNone(webClient, ".o_list_view"); + assert.containsOnce(webClient, ".o_kanban_view"); + assert.verifySteps(["on_close"]); + }); + QUnit.test( "history back calls on_close handler of dialog action with 2 breadcrumbs", async function (assert) {