Skip to content

Commit

Permalink
#8075 Nested Panel preview - unexpected Edit button (#8080)
Browse files Browse the repository at this point in the history
Fixes #8075
  • Loading branch information
novikov82 committed Apr 9, 2024
1 parent d7e6eaf commit 4049af1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { DragDropPanelHelperV1 } from "./drag-drop-panel-helper-v1";
import { DragDropInfo } from "./drag-drop-helper-v1";
import { AnimationGroup, IAnimationConsumer } from "./utils/animation";
import { DomDocumentHelper, DomWindowHelper } from "./global_variables_utils";
import { PageModel } from "./page";

export class QuestionRowModel extends Base {
private static rowCounter = 100;
Expand Down Expand Up @@ -2030,7 +2031,7 @@ export class PanelModel extends PanelModelBase implements IElement {
return this.footerToolbarValue;
}
public get hasEditButton(): boolean {
if (this.survey && this.survey.state === "preview") return this.depth === 1;
if (this.survey && this.survey.state === "preview") return (this.parent && this.parent instanceof PageModel);
return false;
}
public cancelPreview() {
Expand Down
43 changes: 43 additions & 0 deletions tests/surveyShowPreviewTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,49 @@ QUnit.test(
assert.equal(survey.currentPageNo, 1, "We are editing the second page");
}
);
QUnit.test(
"showPreviewBeforeComplete = 'showAllQuestions', edit page",
function (assert) {
StylesManager.applyTheme("default");
var survey = new SurveyModel({
"pages": [
{
"name": "page1",
"elements": [
{
"type": "paneldynamic",
"name": "question1",
"defaultValue": [
{
"question2": "qwe"
}
],
"templateElements": [
{
"type": "panel",
"name": "panel1",
"elements": [
{
"type": "text",
"name": "question2"
}
]
}
]
}
]
}
],
"showPreviewBeforeComplete": "showAllQuestions"
});
survey.showPreviewBeforeComplete = "showAllQuestions";
survey.currentPageNo = 0;
assert.notOk(survey.getAllQuestions()[0].visiblePanels[0].elements[0].hasEditButton, "There is no edit button");
survey.showPreview();

assert.notOk(survey.getAllQuestions()[0].visiblePanels[0].elements[0].hasEditButton, "There is no edit button on preview");
}
);
QUnit.test(
"showPreviewBeforeComplete = 'showAnsweredQuestions', edit page",
function(assert) {
Expand Down

0 comments on commit 4049af1

Please sign in to comment.