Skip to content

Commit

Permalink
FIx creator tests. Do not re-create rows on creating them
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Sep 16, 2024
1 parent 3fdbdc7 commit e2886e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/survey-core/src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1709,23 +1709,27 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
protected isColumnVisible(column: any): boolean {
return column.isColumnVisible;
}
private isGenereatingRows: boolean;
protected getVisibleRows(): Array<MatrixDropdownRowModelBase> {
if (this.isUpdateLocked) return null;
if(this.isGenereatingRows) return [];
if(!!this.visibleRowsArray) return this.visibleRowsArray;
this.generateVisibleRowsIfNeeded();
this.visibleRowsArray = this.getVisibleFromGenerated(this.generatedVisibleRows);
if (this.data) {
this.runCellsCondition(
this.data.getFilteredValues(),
this.data.getFilteredProperties()
);
}
return this.visibleRowsArray;
}
private generateVisibleRowsIfNeeded(): void {
if (!this.isUpdateLocked && !this.generatedVisibleRows) {
if (!this.isUpdateLocked && !this.generatedVisibleRows && !this.generatedVisibleRows) {
this.isGenereatingRows = true;
this.generatedVisibleRows = this.generateRows();
this.isGenereatingRows = false;
this.generatedVisibleRows.forEach((row) => this.onMatrixRowCreated(row));
if (this.data) {
this.runCellsCondition(
this.data.getFilteredValues(),
this.data.getFilteredProperties()
);
}
if(!!this.generatedVisibleRows) {
this.updateValueOnRowsGeneration(this.generatedVisibleRows);
this.updateIsAnswered();
Expand Down
1 change: 1 addition & 0 deletions packages/survey-core/src/question_matrixdynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export class QuestionMatrixDynamicModel extends QuestionMatrixDropdownModelBase
}
if (this.generatedVisibleRows || prevValue == 0) {
if (!this.generatedVisibleRows) {
this.clearGeneratedRows();
this.generatedVisibleRows = [];
}
this.generatedVisibleRows.splice(val);
Expand Down

0 comments on commit e2886e9

Please sign in to comment.