From e2886e92f45f21228ffb9b5b7f674e347c671754 Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Mon, 16 Sep 2024 23:32:29 +0300 Subject: [PATCH] FIx creator tests. Do not re-create rows on creating them --- .../src/question_matrixdropdownbase.ts | 18 +++++++++++------- .../survey-core/src/question_matrixdynamic.ts | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/survey-core/src/question_matrixdropdownbase.ts b/packages/survey-core/src/question_matrixdropdownbase.ts index 0edec25957..30cc31257c 100644 --- a/packages/survey-core/src/question_matrixdropdownbase.ts +++ b/packages/survey-core/src/question_matrixdropdownbase.ts @@ -1709,23 +1709,27 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel { 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(); diff --git a/packages/survey-core/src/question_matrixdynamic.ts b/packages/survey-core/src/question_matrixdynamic.ts index e883a2e8e0..e51849b7eb 100644 --- a/packages/survey-core/src/question_matrixdynamic.ts +++ b/packages/survey-core/src/question_matrixdynamic.ts @@ -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);