Skip to content

Commit

Permalink
[FIX] sheetUi: a spilled cell has no core content
Browse files Browse the repository at this point in the history
The spilled cell of a formula don't have any content.
As such, when choosing to display the formula, those cells
should be empty and not display their evaluated value.

closes #4824

Task: 4105162
X-original-commit: bee93a4
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
rrahir committed Aug 10, 2024
1 parent 5c2ff79 commit d534292
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/plugins/ui_feature/ui_sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export class SheetUIPlugin extends UIPlugin {
const cell = this.getters.getCell(position);
if (showFormula && cell?.isFormula) {
return localizeFormula(cell.content, this.getters.getLocale());
} else if (showFormula && !cell?.content) {
return "";
} else {
return this.getters.getEvaluatedCell(position).formattedValue;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/renderer_store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,19 @@ describe("renderer", () => {
expect(borderRenderingContext).toEqual([[1, [[1, 1]]]]);
});

test("Cells of splilled formula are empty is we display the formulas", () => {
const model = new Model({ sheets: [{ colNumber: 2, rowNumber: 2 }] });
model.dispatch("SET_FORMULA_VISIBILITY", { show: true });
setCellContent(model, "A1", "=MUNIT(2)");
const { drawGridRenderer, gridRendererStore } = setRenderer(model);
let ctx = new MockGridRenderingContext(model, 1000, 1000, {});
drawGridRenderer(ctx);
//@ts-expect-error
const boxes = gridRendererStore.getGridBoxes();
const boxesText = boxes.map((box) => box.content?.textLines.join(""));
expect(boxesText).toEqual(["=MUNIT(2)", "", "", ""]);
});

describe("DataValidations are correctly rendered", () => {
let renderedTexts: string[];
let ctx: MockGridRenderingContext;
Expand Down

0 comments on commit d534292

Please sign in to comment.