Skip to content

Commit 2a23ddd

Browse files
committed
[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. closes #7409 Task: 5244798 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
1 parent a8ebab8 commit 2a23ddd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/helpers/reference_type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Token } from "../formulas";
33
import { EnrichedToken, composerTokenize } from "../formulas/composer_tokenizer";
44
import { Locale } from "../types";
5+
import { getCanonicalSymbolName } from "./misc";
56
import { getFullReference, splitReference } from "./references";
67

78
type FixedReferenceType = "col" | "row" | "colrow" | "none";
@@ -53,7 +54,7 @@ function getTokenNextReferenceType(xc: string): string {
5354
export function setXcToFixedReferenceType(xc: string, referenceType: FixedReferenceType): string {
5455
let sheetName;
5556
({ sheetName, xc } = splitReference(xc));
56-
sheetName = sheetName ? sheetName + "!" : "";
57+
sheetName = sheetName ? getCanonicalSymbolName(sheetName) + "!" : "";
5758

5859
xc = xc.replace(/\$/g, "");
5960
const splitIndex = xc.indexOf(":");

tests/composer/standalone_composer_component.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ describe("Spreadsheet integrations tests", () => {
149149
expect(composerEl.textContent).toBe("=Sheet1!A1");
150150
});
151151

152+
test("content with references from another sheet having space in name adds single quotes", async () => {
153+
await openSidePanelWithComposer({ defaultStatic: true });
154+
await editStandaloneComposer(composerSelector, "=", { confirm: false });
155+
createSheet(model, { sheetId: "sheet2", name: "second sheet", activate: true });
156+
await simulateClick(".o-grid-overlay", 300, 200);
157+
expect(composerEl.textContent).toBe("='second sheet'!$D$9");
158+
});
159+
152160
test("display the content from the props when inactive", async () => {
153161
await openSidePanelWithComposer({ composerContent: "content from props" });
154162
await editStandaloneComposer(composerSelector, "edited", { confirm: false });

0 commit comments

Comments
 (0)