From f1b09ed5b0f12fc949ecdd23db5d3d0bb08a2b2c Mon Sep 17 00:00:00 2001 From: rmbh-odoo Date: Thu, 6 Nov 2025 12:41:19 +0530 Subject: [PATCH] [FIX] reference_type: add single quotes for sheet names with spaces Before this commit: - 'splitReference' removed single quotes from sheet names. After this commit: - Applied 'getCanonicalSymbolName' after 'splitReference' to ensure sheet Names with spaces keep their quotes. Task: 5244798 --- src/helpers/reference_type.ts | 3 ++- tests/composer/standalone_composer_component.test.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/helpers/reference_type.ts b/src/helpers/reference_type.ts index 2515406a98..8644d0f81c 100644 --- a/src/helpers/reference_type.ts +++ b/src/helpers/reference_type.ts @@ -2,6 +2,7 @@ import { Token } from "../formulas"; import { EnrichedToken, composerTokenize } from "../formulas/composer_tokenizer"; import { Locale } from "../types"; +import { getCanonicalSymbolName } from "./misc"; import { getFullReference, splitReference } from "./references"; type FixedReferenceType = "col" | "row" | "colrow" | "none"; @@ -53,7 +54,7 @@ function getTokenNextReferenceType(xc: string): string { export function setXcToFixedReferenceType(xc: string, referenceType: FixedReferenceType): string { let sheetName; ({ sheetName, xc } = splitReference(xc)); - sheetName = sheetName ? sheetName + "!" : ""; + sheetName = sheetName ? getCanonicalSymbolName(sheetName) + "!" : ""; xc = xc.replace(/\$/g, ""); const splitIndex = xc.indexOf(":"); diff --git a/tests/composer/standalone_composer_component.test.ts b/tests/composer/standalone_composer_component.test.ts index dd3fdf0f67..842286a607 100644 --- a/tests/composer/standalone_composer_component.test.ts +++ b/tests/composer/standalone_composer_component.test.ts @@ -149,6 +149,14 @@ describe("Spreadsheet integrations tests", () => { expect(composerEl.textContent).toBe("=Sheet1!A1"); }); + test("content with references from another sheet having space in name adds single quotes", async () => { + await openSidePanelWithComposer({ defaultStatic: true }); + await editStandaloneComposer(composerSelector, "=", { confirm: false }); + createSheet(model, { sheetId: "sheet2", name: "second sheet", activate: true }); + await simulateClick(".o-grid-overlay", 300, 200); + expect(composerEl.textContent).toBe("='second sheet'!$D$9"); + }); + test("display the content from the props when inactive", async () => { await openSidePanelWithComposer({ composerContent: "content from props" }); await editStandaloneComposer(composerSelector, "edited", { confirm: false });