Skip to content

Commit 93ceb2c

Browse files
committed
[FIX] cell_composer_store: formula inputs violating blocking data validation
Previously, formulas returning 1x1 matrices that do not satisfy blocking data validation rules were incorrectly accepted as valid inputs. Now, such formulas are correctly rejected, preventing invalid data entry when the validation rule is blocking. closes #6706 Task: 4876691 X-original-commit: 629280f Signed-off-by: Lucas Lefèvre (lul) <[email protected]> Signed-off-by: Dhrutik Patel (dhrp) <[email protected]>
1 parent 28f579a commit 93ceb2c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/components/composer/composer/cell_composer_store.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isMultipleElementMatrix, toScalar } from "../../../functions/helper_matrices";
12
import { parseLiteral } from "../../../helpers/cells";
23
import {
34
formatValue,
@@ -285,11 +286,14 @@ export class CellComposerStore extends AbstractComposerStore {
285286
? this.getters.evaluateFormula(this.sheetId, content)
286287
: parseLiteral(content, this.getters.getLocale());
287288

288-
if (isMatrix(cellValue)) {
289+
if (isMultipleElementMatrix(cellValue)) {
289290
return true;
290291
}
291292

292-
const validationResult = this.getters.getValidationResultForCellValue(cellValue, cellPosition);
293+
const validationResult = this.getters.getValidationResultForCellValue(
294+
toScalar(cellValue),
295+
cellPosition
296+
);
293297
if (!validationResult.isValid && validationResult.rule.isBlocking) {
294298
return false;
295299
}

tests/data_validation/data_validation_blocking_component.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,12 @@ describe("Data validation with blocking rule", () => {
118118

119119
expect(getCellContent(model, "A1")).toBe("1");
120120
});
121+
122+
test("User cannot input formula returning 1x1 matrix that fails blocking DV rule", async () => {
123+
addDataValidation(model, "A1", "id", { type: "containsText", values: ["hi"] }, "blocking");
124+
composerStore.startEdition('=IF(TRUE, A2, "something else")');
125+
composerStore.stopEdition();
126+
127+
expect(getCellContent(model, "A1")).toBe("");
128+
});
121129
});

0 commit comments

Comments
 (0)