mirror of
https://github.com/dream-num/univer.git
synced 2026-09-24 15:32:18 +08:00
fix(sheets-data-validation): data validation event trigger before data applied (#3498)
This commit is contained in:
@@ -145,24 +145,28 @@ export class DataValidationModel extends Disposable {
|
||||
if (oldRule) {
|
||||
return;
|
||||
}
|
||||
this._ruleChange$.next({
|
||||
|
||||
return {
|
||||
rule,
|
||||
type: 'add',
|
||||
unitId,
|
||||
subUnitId,
|
||||
source,
|
||||
});
|
||||
} as const;
|
||||
}
|
||||
|
||||
addRule(unitId: string, subUnitId: string, rule: IDataValidationRule | IDataValidationRule[], source: DataValidationChangeSource, index?: number) {
|
||||
try {
|
||||
const subUnitMap = this._ensureMap(unitId, subUnitId);
|
||||
const rules = Array.isArray(rule) ? rule : [rule];
|
||||
rules.forEach((item) => {
|
||||
this._addRuleSideEffect(unitId, subUnitId, item, source);
|
||||
});
|
||||
const effects = rules.map((item) => this._addRuleSideEffect(unitId, subUnitId, item, source));
|
||||
|
||||
this._addSubUnitRule(subUnitMap, rule, index);
|
||||
effects.forEach((effect) => {
|
||||
if (effect) {
|
||||
this._ruleChange$.next(effect);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
this._logService.error(error);
|
||||
}
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ export class DocThreadCommentSelectionController extends Disposable {
|
||||
const doc = this._univerInstanceService.getUnit<DocumentDataModel>(activeComment.unitId);
|
||||
if (doc) {
|
||||
const backScrollController = this._renderManagerService.getRenderById(activeComment.unitId)?.with(DocBackScrollRenderController);
|
||||
const customRange = doc.getCustomRanges()?.find((range) => range.rangeId === activeComment.commentId);
|
||||
const customRange = doc.getBody()?.customDecorations?.find((range) => range.id === activeComment.commentId);
|
||||
if (customRange && backScrollController) {
|
||||
backScrollController.scrollToRange({
|
||||
startOffset: customRange.startIndex,
|
||||
|
||||
@@ -98,12 +98,13 @@ export class SheetDataValidationModel extends Disposable {
|
||||
unitMap = new Map();
|
||||
this._ruleMatrixMap.set(unitId, unitMap);
|
||||
}
|
||||
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
||||
if (!worksheet) {
|
||||
throw new Error(`worksheet not found, unitId: ${unitId}, subUnitId: ${subUnitId}`);
|
||||
}
|
||||
|
||||
let matrix = unitMap.get(subUnitId);
|
||||
if (!matrix) {
|
||||
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
||||
if (!worksheet) {
|
||||
throw new Error(`worksheet not found, unitId: ${unitId}, subUnitId: ${subUnitId}`);
|
||||
}
|
||||
matrix = new RuleMatrix(new Map(), worksheet);
|
||||
unitMap.set(subUnitId, matrix);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user