Skip to content

Commit 04b8575

Browse files
committed
[FIX] references: 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 #7465 Task: 5244798 X-original-commit: 2a23ddd Signed-off-by: Lucas Lefèvre (lul) <[email protected]> Signed-off-by: Ronakkumar Mukeshbhai Bharadiya (rmbh) <[email protected]>
1 parent 219b738 commit 04b8575

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/o-spreadsheet-engine/src/helpers/references.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function getTokenNextReferenceType(xc: string): string {
101101
export function setXcToFixedReferenceType(xc: string, referenceType: FixedReferenceType): string {
102102
let sheetName;
103103
({ sheetName, xc } = splitReference(xc));
104-
sheetName = sheetName ? sheetName + "!" : "";
104+
sheetName = sheetName ? getCanonicalSymbolName(sheetName) + "!" : "";
105105

106106
xc = xc.replace(/\$/g, "");
107107
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
@@ -150,6 +150,14 @@ describe("Spreadsheet integrations tests", () => {
150150
expect(composerEl.textContent).toBe("=Sheet1!A1");
151151
});
152152

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

0 commit comments

Comments
 (0)