Skip to content

Commit

Permalink
Fix: Navigation issue with onProgressText callback and questionOrder …
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov authored Sep 28, 2021
1 parent eca7650 commit f7e45a2
Show file tree
Hide file tree
Showing 2 changed files with 62 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 @@ -985,6 +985,7 @@ export class PanelModelBase extends SurveyElement
this.id
);
this.updateRowsOnElementRemoved(element);
if(this.isRandomizing) return;
if (!element.isPanel) {
if (this.survey) this.survey.questionRemoved(<Question>element);
} else {
Expand All @@ -994,7 +995,7 @@ export class PanelModelBase extends SurveyElement
this.onElementVisibilityChanged(this);
}
private onElementVisibilityChanged(element: any) {
if (this.isLoadingFromJson) return;
if (this.isLoadingFromJson || this.isRandomizing) return;
this.updateRowsVisibility(element);
this.childVisibilityChanged();
if (!!this.parent) {
Expand Down
60 changes: 60 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,66 @@ QUnit.test(
assert.equal(survey.progressText, "Answered: 50%");
}
);
QUnit.test("onProgressText event and questionOrder in page, Bug#3383", function (assert) {
var survey = new SurveyModel({
"pages": [
{
name: "page1",
"elements": [
{
"name": "q1",
"type": "radiogroup",
"choices": [1, 2, 3],
},
],
},
{
name: "page2",
"elements": [
{
"name": "q2",
"type": "text",
},
{
"name": "q3",
"type": "radiogroup",
choices: [1, 2, 3],
}
]
},
{
name: "page3",
"elements": [
{
"name": "q4",
"choices": [1, 2, 3],
"type": "radiogroup"
},
{
"name": "q5",
"type": "text",
}
],
"questionsOrder": "random"
}
],
});
var oldCurrentPageName: string;
var newCurrentPageName: string;
survey.onCurrentPageChanged.add((sender, options) => {
oldCurrentPageName = !!options.oldCurrentPage? options.oldCurrentPage.name : "";
newCurrentPageName = !!options.newCurrentPage? options.newCurrentPage.name : "";
});
survey.onProgressText.add(() => { var dummy = 1; });
survey.nextPage();
assert.equal(oldCurrentPageName, "page1", "First nextPage, old");
assert.equal(newCurrentPageName, "page2", "First nextPage, new");
survey.nextPage();
assert.equal(survey.currentPageNo, 2, "We are on the last page");
assert.equal(oldCurrentPageName, "page2", "Second nextPage, old");
assert.equal(newCurrentPageName, "page3", "Second nextPage, new");
});

QUnit.test("progressText, 'requiredQuestions' type and design mode", function (
assert
) {
Expand Down

0 comments on commit f7e45a2

Please sign in to comment.