From 8e6cb290be22b01c42d1ab4c0a36447c9815c670 Mon Sep 17 00:00:00 2001 From: Aleksey Novikov Date: Tue, 16 Apr 2024 16:31:24 +0300 Subject: [PATCH] fixed siglepage mode preview fail for dynamic panel (#8122) --- src/panel.ts | 2 +- tests/surveytests.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/panel.ts b/src/panel.ts index fdc9394c0f..0399c39247 100644 --- a/src/panel.ts +++ b/src/panel.ts @@ -2073,7 +2073,7 @@ export class PanelModel extends PanelModelBase implements IElement { return super.getIsNested() && this.parent !== undefined; } public get showPanelAsPage(): boolean { - return !!(this).originalPage || (this.survey).isShowingPreview && (this.survey).isSinglePage && !!(this).parent.originalPage; + return !!(this).originalPage || (this.survey).isShowingPreview && (this.survey).isSinglePage && !!(this).parent && !!(this).parent.originalPage; } protected getCssRoot(cssClasses: { [index: string]: string }): string { return new CssClassBuilder() diff --git a/tests/surveytests.ts b/tests/surveytests.ts index 349e001c8e..f9be5225d7 100644 --- a/tests/surveytests.ts +++ b/tests/surveytests.ts @@ -19544,3 +19544,37 @@ QUnit.test("showPreview & updateProgress & updateVisibleIndexes", function ( assert.equal(progressCounter, 1, "progressCounter"); assert.equal(visibleChangedCounter, 0, "visibleChangedCounter"); }); + +QUnit.test("showPreview & dynamic panel? single page", function ( + assert +) { + const survey = new SurveyModel({ + "pages": [ + { + "name": "page1", + "elements": [ + { + "type": "paneldynamic", + "name": "question1", + "defaultValue": [ + { + "question2": "q" + } + ], + "templateElements": [ + { + "type": "text", + "name": "question2" + } + ] + } + ] + } + ], + "questionsOnPageMode": "singlePage", + "showPreviewBeforeComplete": "showAllQuestions" + }); + survey.showPreview(); + assert.notOk((survey.getQuestionByName("question1") as QuestionPanelDynamicModel).panels[0].showPanelAsPage); +}); +