Skip to content

Commit

Permalink
Merge pull request #8584 from surveyjs/bug/8583-question-hash-firstpa…
Browse files Browse the repository at this point in the history
…ge-pagemode

Question is not in the hash with it is on the first page & questionsO…
  • Loading branch information
OlgaLarina authored Jul 19, 2024
2 parents 8c12272 + 917386d commit e6721af
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4297,6 +4297,9 @@ export class SurveyModel extends SurveyElementCore
private isLockingUpdateOnPageModes: boolean;
private setupPagesForPageModes(isSinglePage: boolean, isFirstLoad: boolean) {
this.questionHashesClear();
if(this.firstPageIsStarted && this.pages.length > 0) {
this.pages[0].questions.forEach(q => this.questionHashesAdded(q));
}
this.isLockingUpdateOnPageModes = !isFirstLoad;
var startIndex = this.getPageStartIndex();
super.startLoadingFromJson();
Expand Down
42 changes: 42 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20247,4 +20247,46 @@ QUnit.test("survey navigateToUrl encode url", function (assert) {

survey.doComplete();
assert.equal(location.href, "javascript%3Aalert(2)", "encoded URL");
});
QUnit.test("Question is not in the hash with it is on the first page & questionsOnPageMode is 'questionPerPage', Bug#8583", function (assert) {
const survey = new SurveyModel({
"pages": [{
"elements": [{
"type": "text",
"name": "q1"
}
]
},
{
"elements": [{
"type": "text",
"name": "q2"
}] }],
"firstPageIsStarted": true,
"questionsOnPageMode": "questionPerPage",
});

const q = survey.getQuestionByName("q1");
assert.equal(q.name, "q1", "q1 name is here");
});
QUnit.test("Question is not in the hash with it is on the first page & questionsOnPageMode is 'singlePage', Bug#8583", function (assert) {
const survey = new SurveyModel({
"pages": [{
"elements": [{
"type": "text",
"name": "q1"
}
]
},
{
"elements": [{
"type": "text",
"name": "q2"
}] }],
"firstPageIsStarted": true,
"questionsOnPageMode": "singlePage",
});

const q = survey.getQuestionByName("q1");
assert.equal(q.name, "q1", "q1 name is here");
});

0 comments on commit e6721af

Please sign in to comment.