From a93564cd381ff17171ebe8381bf9c9de5afbc793 Mon Sep 17 00:00:00 2001 From: rmbh-odoo Date: Fri, 10 Oct 2025 11:33:50 +0530 Subject: [PATCH] [FIX] composer: set editionMode to inactive when composer is unmounted Steps to reproduce: - Open the CF side panel and edit a StandaloneComposer inside a color scale. - Switch the sheet. The panel closes, so the composer is unmounted. - Previously, the composer remained in editing mode after unmount. Before this commit: - Unmounting the composer did not set editionMode to inactive. - This caused focus issues in other parts of the UI. After this commit: - Unmounting the composer sets editionMode to inactive. - Focus and selection are now properly released. Task: 5149215 --- .../composer/abstract_composer_store.ts | 1 + ...itional_formatting_panel_component.test.ts | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/components/composer/composer/abstract_composer_store.ts b/src/components/composer/composer/abstract_composer_store.ts index edc1e0bcea..83fdf08544 100644 --- a/src/components/composer/composer/abstract_composer_store.ts +++ b/src/components/composer/composer/abstract_composer_store.ts @@ -93,6 +93,7 @@ export abstract class AbstractComposerStore extends SpreadsheetStore { this.highlightStore.register(this); this.onDispose(() => { this.highlightStore.unRegister(this); + this._cancelEdition(); }); } protected abstract confirmEdition(content: string): void; diff --git a/tests/conditional_formatting/conditional_formatting_panel_component.test.ts b/tests/conditional_formatting/conditional_formatting_panel_component.test.ts index d84ca9d16b..8afe695fca 100644 --- a/tests/conditional_formatting/conditional_formatting_panel_component.test.ts +++ b/tests/conditional_formatting/conditional_formatting_panel_component.test.ts @@ -1,5 +1,6 @@ import { Component } from "@odoo/owl"; import { Model } from "../../src"; +import { ComposerFocusStore } from "../../src/components/composer/composer_focus_store"; import { ConditionalFormattingPanel } from "../../src/components/side_panel/conditional_formatting/conditional_formatting"; import { toHex, toZone } from "../../src/helpers"; import { ConditionalFormatPlugin } from "../../src/plugins/core/conditional_format"; @@ -1571,4 +1572,26 @@ describe("Integration tests", () => { expect(fixture.querySelector(selectors.ruleEditor.range)).toBeNull(); expect(fixture.querySelector(selectors.listPreview)).toBeDefined(); }); + + test("CF standalone composer becomes inactive on sheet change", async () => { + const sheetId = model.getters.getActiveSheetId(); + model.dispatch("ADD_CONDITIONAL_FORMAT", { + cf: createEqualCF("2", { bold: true, fillColor: "#ff0000" }, "99"), + ranges: toRangesData(sheetId, "A1:A2"), + sheetId, + }); + createSheet(model, { sheetId: "42" }); + const zone = toZone("A1:A2"); + parent.env.openSidePanel("ConditionalFormatting", { selection: [zone] }); + await nextTick(); + await editStandaloneComposer(selectors.ruleEditor.editor.valueInput, "=", { + confirm: false, + }); + const composerFocusStore = parent.env.getStore(ComposerFocusStore); + expect(composerFocusStore.activeComposer.id).toBe("standaloneComposer"); + expect(composerFocusStore.activeComposer.editionMode).toBe("selecting"); + activateSheet(model, "42"); + await nextTick(); + expect(composerFocusStore.activeComposer.editionMode).toBe("inactive"); + }); });