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): error relayout on ref-range change (#4376)
zhangw70f82d02ab74
diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.tsindex 4101b57a08..374351d195 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts@@ -49,7 +49,10 @@ export class DataValidationAlertController extends Disposable {const worksheet = workbook.getSheetBySheetId(cellPos.location.subUnitId);if (!worksheet) return;const rule = this._dataValidationModel.getRuleByLocation(cellPos.location.unitId, cellPos.location.subUnitId, cellPos.location.row, cellPos.location.col);- if (!rule) return;+ if (!rule) {+ this._cellAlertManagerService.removeAlert(ALERT_KEY);+ return;+ }const validStatus = this._dataValidationModel.validator(rule, { ...cellPos.location, workbook, worksheet });if (validStatus === DataValidationStatus.INVALID) {@@ -62,11 +65,13 @@ export class DataValidationAlertController extends Disposable {currentLoc.subUnitId === cellPos.location.subUnitId &¤tLoc.unitId === cellPos.location.unitId) {+ this._cellAlertManagerService.removeAlert(ALERT_KEY);return;}const validator = this._dataValidationModel.getValidator(rule.type) as BaseDataValidator;if (!validator) {+ this._cellAlertManagerService.removeAlert(ALERT_KEY);return;}this._cellAlertManagerService.showAlert({diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.tsindex 9821d19dc4..e383c16ca3 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts@@ -248,13 +248,19 @@ export class SheetsDataValidationRenderController extends RxDisposable {// patched data-validation change don't need to re-calc row height// re-calc of row height will be triggered precisely by the origin commandfilter((change) => change.source === 'command'),- bufferTime(16)+ bufferTime(100)).subscribe((infos) => {+ if (infos.length === 0) {+ return;+ }+const ranges: IRange[] = [];infos.forEach((info) => {- if (info.rule?.ranges) {- ranges.push(...info.rule.ranges);+ if (info.rule.type === DataValidationType.LIST_MULTIPLE || info.rule.type === DataValidationType.LIST) {+ if (info.rule?.ranges) {+ ranges.push(...info.rule.ranges);+ }}});diff --git a/packages/sheets-data-validation/src/controllers/dv-formula-ref-range.controller.ts b/packages/sheets-data-validation/src/controllers/dv-formula-ref-range.controller.tsindex da8e967d79..b7374e4f08 100644--- a/packages/sheets-data-validation/src/controllers/dv-formula-ref-range.controller.ts+++ b/packages/sheets-data-validation/src/controllers/dv-formula-ref-range.controller.ts@@ -61,6 +61,7 @@ export class DataValidationFormulaRefRangeController extends Disposable {unitId,subUnitId,rule,+ source: 'patched',},}],redos: [{@@ -69,6 +70,7 @@ export class DataValidationFormulaRefRangeController extends Disposable {unitId,subUnitId,ruleId: rule.uid,+ source: 'patched',},}],};@@ -90,6 +92,7 @@ export class DataValidationFormulaRefRangeController extends Disposable {formula2: first.formulas[1],},},+ source: 'patched',} as IUpdateDataValidationMutationParams,});undos.push({@@ -106,6 +109,7 @@ export class DataValidationFormulaRefRangeController extends Disposable {formula2: oldFormula2,},},+ source: 'patched',},});@@ -124,6 +128,7 @@ export class DataValidationFormulaRefRangeController extends Disposable {formula2: item.formulas[1],ranges: item.ranges,},+ source: 'patched',},});undos.push({@@ -132,6 +137,7 @@ export class DataValidationFormulaRefRangeController extends Disposable {unitId,subUnitId,ruleId: id,+ source: 'patched',},});}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 ea81e89510..c5ce83c9a9 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@@ -53,6 +53,7 @@ export class DataValidationRefRangeController extends Disposable {this.registerFormula(unitId, subUnitId, rule);};+ // eslint-disable-next-line max-lines-per-functionregisterFormula(unitId: string, subUnitId: string, rule: ISheetDataValidationRule) {const ruleId = rule.uid;const id = this._getIdWithUnitId(unitId, subUnitId, ruleId);@@ -79,6 +80,7 @@ export class DataValidationRefRangeController extends Disposable {[type]: formulaString,},},+ source: 'patched',};const undoParams: IUpdateDataValidationMutationParams = {unitId,@@ -92,6 +94,7 @@ export class DataValidationRefRangeController extends Disposable {formula2: oldRule.formula2,},},+ source: 'patched',};const redos = [{