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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheets-data-validation): ref-range (#3533)
zhangwf7f8269acb81
diff --git a/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.ts b/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.tsindex 9131c0234d..db7069439a 100644--- a/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.ts+++ b/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.ts@@ -18,7 +18,7 @@ import { DataValidationType, Disposable, Inject, Injector, isRangesEqual, Lifecyimport { RemoveDataValidationMutation, UpdateDataValidationMutation, UpdateRuleType } from '@univerjs/data-validation';import { handleCommonDefaultRangeChangeWithEffectRefCommands, RefRangeService } from '@univerjs/sheets';import { FormulaRefRangeService } from '@univerjs/sheets-formula';-import type { IRange, ISheetDataValidationRule } from '@univerjs/core';+import type { ISheetDataValidationRule } from '@univerjs/core';import type { IRemoveDataValidationMutationParams, IUpdateDataValidationMutationParams } from '@univerjs/data-validation';import type { EffectRefRangeParams } from '@univerjs/sheets';import { removeDataValidationUndoFactory } from '../commands/commands/data-validation.command';@@ -145,7 +145,7 @@ export class DataValidationRefRangeController extends Disposable {const handleRangeChange = (commandInfo: EffectRefRangeParams) => {const oldRanges = [...rule.ranges];const resultRangesOrigin = oldRanges.map((range) => {- return handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo) as IRange | IRange[];+ return handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo);}).filter((range) => !!range);const resultRanges = resultRangesOrigin.flat();@@ -201,6 +201,15 @@ export class DataValidationRefRangeController extends Disposable {};private _initRefRange() {+ const allRules = this._dataValidationModel.getAll();+ for (const [unitId, subUnitMap] of allRules) {+ for (const [subUnitId, rules] of subUnitMap) {+ for (const rule of rules) {+ this.registerRule(unitId, subUnitId, rule);+ }+ }+ }+this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe((option) => {const { unitId, subUnitId, rule } = option;diff --git a/packages/sheets/src/services/ref-range/util.ts b/packages/sheets/src/services/ref-range/util.tsindex 18a93c6cc0..03231044a5 100644--- a/packages/sheets/src/services/ref-range/util.ts+++ b/packages/sheets/src/services/ref-range/util.ts@@ -1013,7 +1013,7 @@ type MutationsAffectRange =| IInsertRowMutationParams| IMoveRangeMutationParams;-export const handleCommonDefaultRangeChangeWithEffectRefCommands = (range: IRange, commandInfo: ICommandInfo) => {+export const handleCommonDefaultRangeChangeWithEffectRefCommands = (range: IRange, commandInfo: ICommandInfo): IRange[] => {let operator: IOperator[] = [];switch (commandInfo.id) {case EffectRefRangId.DeleteRangeMoveLeftCommandId: {@@ -1057,7 +1057,7 @@ export const handleCommonDefaultRangeChangeWithEffectRefCommands = (range: IRang}}const resultRange = runRefRangeMutations(operator, range);- return resultRange;+ return resultRange ? [resultRange] : [];};export const handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests = (range: IRange, commandInfo: ICommandInfo, deps: { selectionManagerService: SheetsSelectionsService }) => {