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(data-validation): remove useless interceptor mutations (#3630)

YuHongfd48e15e22eb
diff --git a/packages/sheets-data-validation/src/controllers/dv-sheet.controller.ts b/packages/sheets-data-validation/src/controllers/dv-sheet.controller.ts
index f5db16c852..39ca7858f2 100644
--- a/packages/sheets-data-validation/src/controllers/dv-sheet.controller.ts
+++ b/packages/sheets-data-validation/src/controllers/dv-sheet.controller.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { Disposable, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import { AddDataValidationMutation, RemoveDataValidationMutation } from '@univerjs/data-validation';
-import { RemoveSheetCommand, SheetInterceptorService } from '@univerjs/sheets';
import type { Workbook } from '@univerjs/core';
import type { IAddDataValidationMutationParams, IRemoveDataValidationMutationParams } from '@univerjs/data-validation';
import type { IRemoveSheetCommandParams } from '@univerjs/sheets';
+import { Disposable, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
+import { AddDataValidationMutation, RemoveDataValidationMutation } from '@univerjs/data-validation';
+import { RemoveSheetCommand, SheetInterceptorService } from '@univerjs/sheets';
import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
@OnLifecycle(LifecycleStages.Ready, SheetDataValidationSheetController)
@@ -51,6 +51,11 @@ export class SheetDataValidationSheetController extends Disposable {
}
const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
+
+ if (rules.length === 0) {
+ return { redos: [], undos: [] };
+ }
+
const ids = rules.map((i) => i.uid);
const redoParams: IRemoveDataValidationMutationParams = {
unitId,