Skip to content

Commit

Permalink
fixed siglepage mode preview fail for dynamic panel (#8122)
Browse files Browse the repository at this point in the history
  • Loading branch information
novikov82 authored Apr 16, 2024
1 parent 3bd17bd commit 8e6cb29
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ export class PanelModel extends PanelModelBase implements IElement {
return super.getIsNested() && this.parent !== undefined;
}
public get showPanelAsPage(): boolean {
return !!(<any>this).originalPage || (<any>this.survey).isShowingPreview && (<any>this.survey).isSinglePage && !!(<any>this).parent.originalPage;
return !!(<any>this).originalPage || (<any>this.survey).isShowingPreview && (<any>this.survey).isSinglePage && !!(<any>this).parent && !!(<any>this).parent.originalPage;
}
protected getCssRoot(cssClasses: { [index: string]: string }): string {
return new CssClassBuilder()
Expand Down
34 changes: 34 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 8e6cb29

Please sign in to comment.