Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheets-data-validation): data-validation range set error (#4378)

zhangw6ed7d8406bb1
diff --git a/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx b/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
index 62bca6e8fa..0982189416 100644
--- a/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
@@ -117,7 +117,7 @@ export function DataValidationDetail() {
};
const handleUpdateRuleRanges = useEvent((rangeText: string) => {
- const unitRanges = rangeText.split(',').map(deserializeRangeWithSheet).map((unitRange) => {
+ const unitRanges = rangeText.split(',').filter(Boolean).map(deserializeRangeWithSheet).map((unitRange) => {
const sheetName = unitRange.sheetName;
if (sheetName) {
const sheetId = getSheetIdByName(univerInstanceService, unitRange.unitId, sheetName);
diff --git a/packages/sheets-data-validation/src/models/rule-matrix.ts b/packages/sheets-data-validation/src/models/rule-matrix.ts
index 008f34f686..de6271755e 100644
--- a/packages/sheets-data-validation/src/models/rule-matrix.ts
+++ b/packages/sheets-data-validation/src/models/rule-matrix.ts
@@ -86,7 +86,7 @@ export class RuleMatrix {
return;
}
- const ranges = _ranges.map((range) => Range.transformRange(range, this._worksheet!));
+ const ranges = Rectangle.mergeRanges(_ranges.map((range) => Range.transformRange(range, this._worksheet!)));
this._map.forEach((value, key) => {
const newRanges = Rectangle.subtractMulti(value, ranges);