Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sheets-data-validation): data validation event trigger before data applied #3498

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/data-validation/src/models/data-validation-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading