Skip to content

Commit

Permalink
Fixed #6471 - Buttons Navigation - Buttons should not appear in a Tha…
Browse files Browse the repository at this point in the history
…nk you page after survey completion
  • Loading branch information
tsv2013 committed Jul 5, 2023
1 parent 252f539 commit 68558f1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6999,7 +6999,7 @@ export class SurveyModel extends SurveyElementCore
containerLayoutElements.push(layoutElement);
}
}
} else if(isStrCiEqual(layoutElement.id, "progress-" + this.progressBarType)) {
} else if(this.state === "running" && isStrCiEqual(layoutElement.id, "progress-" + this.progressBarType)) {
if(container === "header") {
if(this.isShowProgressBarOnTop && !this.isShowStartingPage) {
containerLayoutElements.push(layoutElement);
Expand Down
66 changes: 66 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16708,6 +16708,7 @@ QUnit.test("getContainerContent - do not show TOC on preview", function (assert)
assert.deepEqual(getContainerContent("left"), [], "do not show toc left");
assert.deepEqual(getContainerContent("right"), [], "");
});

QUnit.test("getContainerContent - do not show TOC on start page", function (assert) {
const json = {
showTOC: true,
Expand Down Expand Up @@ -16771,6 +16772,71 @@ QUnit.test("getContainerContent - do not show TOC on start page", function (asse
assert.deepEqual(getContainerContent("right"), [], "");
});

QUnit.test("getContainerContent - do not show buttons progress on completed page", function (assert) {
const json = {
"progressBarType": "buttons",
"showProgressBar": "top",
pages: [
{
"elements": [
{
"type": "text",
"name": "q1",
},
]
},
{
"elements": [
{
"type": "text",
"name": "q2",
},
]
},
{
"elements": [
{
"type": "text",
"name": "q3",
},
]
}
]
};

let survey = new SurveyModel(json);
function getContainerContent(container: LayoutElementContainer) {
let result = survey.getContainerContent(container);
result.forEach(item => delete item["data"]);
return result;
}

assert.deepEqual(getContainerContent("header"), [{
"component": "sv-progress-buttons",
"id": "progress-buttons"
}], "");
assert.deepEqual(getContainerContent("footer"), [], "");
assert.deepEqual(getContainerContent("contentTop"), [], "");
assert.deepEqual(getContainerContent("contentBottom"), [{
"component": "sv-action-bar",
"id": "navigationbuttons"
}], "");
assert.deepEqual(getContainerContent("left"), [], "");
assert.deepEqual(getContainerContent("right"), [], "");

survey.doComplete();

assert.deepEqual(getContainerContent("header"), [], "");
assert.deepEqual(getContainerContent("footer"), [], "");
assert.deepEqual(getContainerContent("contentTop"), [], "");
assert.deepEqual(getContainerContent("contentBottom"), [{
"component": "sv-action-bar",
"id": "navigationbuttons"
}], "");
assert.deepEqual(getContainerContent("left"), [], "");
assert.deepEqual(getContainerContent("right"), [], "");
});

const structedDataSurveyJSON = {
pages: [
{
Expand Down

0 comments on commit 68558f1

Please sign in to comment.