Skip to content

Commit

Permalink
Fixed #8260 - Hide the progress bar if questionsOnPageMode: "singlePage"
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed May 14, 2024
1 parent f2a6ed1 commit 1c10bfa
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 12 deletions.
18 changes: 10 additions & 8 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6556,7 +6556,7 @@ export class SurveyModel extends SurveyElementCore
if (this.checkIsCurrentPageHasErrors(false)) return;
const curPage = this.currentPage;
const goNextPage = () => {
if(curPage !== this.currentPage) return;
if (curPage !== this.currentPage) return;
if (!this.isLastPage) {
this.nextPage();
} else {
Expand Down Expand Up @@ -7555,14 +7555,16 @@ export class SurveyModel extends SurveyElementCore
}
}
} else if (isStrCiEqual(layoutElement.id, "buttons-navigation")) {
if (container === "contentTop") {
if (["top", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
containerLayoutElements.push(layoutElement);
if (this.questionsOnPageMode != "singlePage") {
if (container === "contentTop") {
if (["top", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
containerLayoutElements.push(layoutElement);
}
}
}
if (container === "contentBottom") {
if (["bottom", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
containerLayoutElements.push(layoutElement);
if (container === "contentBottom") {
if (["bottom", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
containerLayoutElements.push(layoutElement);
}
}
}
} else if (this.state === "running" && isStrCiEqual(layoutElement.id, "toc-navigation") && this.showTOC) {
Expand Down
47 changes: 43 additions & 4 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19544,7 +19544,8 @@ QUnit.test("showPreview & updateProgress & updateVisibleIndexes", function (
},
{
elements: [
{ type: "paneldynamic", name: "q2", panelCount: 10,
{
type: "paneldynamic", name: "q2", panelCount: 10,
elements: [{ type: "text", name: "q3", visibleIf: "{q1} = 1" }]
},
{ type: "text", name: "q4", visibleIf: "{q1} = 1" }
Expand All @@ -19556,10 +19557,10 @@ QUnit.test("showPreview & updateProgress & updateVisibleIndexes", function (
let progressCounter = 0;
let visibleChangedCounter = 0;
survey.onProgressText.add((sender, options) => {
progressCounter ++;
progressCounter++;
});
survey.onQuestionVisibleChanged.add((sender, options) => {
visibleChangedCounter ++;
visibleChangedCounter++;
});
survey.showPreview();
assert.equal(progressCounter, 1, "progressCounter");
Expand Down Expand Up @@ -19628,4 +19629,42 @@ QUnit.test("check panel's visibleRows are updated sync when running condidtions
assert.equal(panel.visibleRows.length, 1);
assert.equal(panel.visibleRows[0].visibleElements[0].name, "nps-score");
settings.animationEnabled = false;
});
});

QUnit.test("getContainerContent - do not show buttons navigation in the single page mode", function (assert) {
const json = {
pages: [
{
"elements": [
{
"type": "text",
"name": "q1",
},
]
},
]
};

let survey = new SurveyModel(json);
const getContainerContent = getContainerContentFunction(survey);

assert.equal(survey.questionsOnPageMode, "standard");
assert.deepEqual(getContainerContent("header"), [], "");
assert.deepEqual(getContainerContent("footer"), [], "");
assert.deepEqual(getContainerContent("contentTop"), [], "");
assert.deepEqual(getContainerContent("contentBottom"), [{
"component": "sv-action-bar",
"id": "buttons-navigation"
}], "Buttons navigation is shown");
assert.deepEqual(getContainerContent("left"), [], "");
assert.deepEqual(getContainerContent("right"), [], "");

survey.questionsOnPageMode = "singlePage";

assert.deepEqual(getContainerContent("header"), [], "");
assert.deepEqual(getContainerContent("footer"), [], "");
assert.deepEqual(getContainerContent("contentTop"), [], "");
assert.deepEqual(getContainerContent("contentBottom"), [], "No buttons navigation in the single page mode");
assert.deepEqual(getContainerContent("left"), [], "");
assert.deepEqual(getContainerContent("right"), [], "");
});

0 comments on commit 1c10bfa

Please sign in to comment.