From 3488610c5e9df0eb856e3f5cdc99d40ef1dd87a8 Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Fri, 5 Jul 2024 17:26:37 +0300 Subject: [PATCH] If there is a unique error in a cell then detail panel is opened fix #8517 --- src/question_matrixdropdownbase.ts | 7 +++++-- tests/question_matrixdynamictests.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/question_matrixdropdownbase.ts b/src/question_matrixdropdownbase.ts index f9767d8ce8..e7238c9950 100644 --- a/src/question_matrixdropdownbase.ts +++ b/src/question_matrixdropdownbase.ts @@ -2127,14 +2127,17 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel, columnName: string): void { duplicatedRows.forEach(row => { let question = row.getQuestionByName(columnName); - if(!question && this.detailPanel.getQuestionByName(columnName)) { + const inDetailPanel = this.detailPanel.getQuestionByName(columnName); + if(!question && inDetailPanel) { row.showDetailPanel(); if(row.detailPanel) { question = row.detailPanel.getQuestionByName(columnName); } } if(question) { - row.showDetailPanel(); + if(inDetailPanel) { + row.showDetailPanel(); + } this.addDuplicationError(question); } }); diff --git a/tests/question_matrixdynamictests.ts b/tests/question_matrixdynamictests.ts index 1ff50cb412..ee97c28bf9 100644 --- a/tests/question_matrixdynamictests.ts +++ b/tests/question_matrixdynamictests.ts @@ -486,6 +486,33 @@ QUnit.test("Matrixdynamic duplicationError in detailPanel", function (assert) { matrix.value = [{ column1: "val1" }, { column1: "val2" }]; assert.equal(matrix.hasErrors(), false, "There is no errors, row[0].column1=val1 and row[1].column2=val2"); }); +QUnit.test("Matrixdynamic duplicationError and no errors in detailPanel, do not expand panels", function (assert) { + var matrix = new QuestionMatrixDynamicModel("matrixDymanic"); + matrix.rowCount = 2; + matrix.columns.push(new MatrixDropdownColumn("column1")); + matrix.columns.push(new MatrixDropdownColumn("column2")); + matrix.detailPanelMode = "underRow"; + matrix.detailPanel.addNewQuestion("text", "col_q1"); + matrix.columns[0].isUnique = true; + assert.equal(matrix.hasErrors(), false, "No errors"); + matrix.value = [{ column1: "val1" }, {}]; + assert.equal( + matrix.hasErrors(), + false, + "There is no errors, row[0].column1=val1" + ); + const rows = matrix.visibleRows; + assert.equal(rows[0].isDetailPanelShowing, false, "detail panel row0 is showing, #1"); + assert.equal(rows[1].isDetailPanelShowing, false, "detail panel row1 is showing, #2"); + rows[1].getQuestionByName("column1").value = "val1"; + assert.equal( + matrix.hasErrors(), + true, + "There is the error, row[0].column1=val1 and row[1].column2=val1" + ); + assert.equal(rows[0].isDetailPanelShowing, false, "detail panel row0 is showing, #3"); + assert.equal(rows[1].isDetailPanelShowing, false, "detail panel row1 is showing, #4"); +}); QUnit.test("Matrixdynamic: remove duplicationError in cells and in detailPanels", function (assert) { var matrix = new QuestionMatrixDynamicModel("matrixDymanic");