From 775e1490789caaf3dcf8c081bc832b2acd29859f Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Fri, 19 Jul 2024 14:55:02 +0300 Subject: [PATCH] Question is not in the hash with it is on the first page & questionsOnPageMode is 'questionPerPage' fix #8583 --- src/survey.ts | 3 +++ tests/surveytests.ts | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/survey.ts b/src/survey.ts index dc86c927c5..f51576fb68 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -4297,6 +4297,9 @@ export class SurveyModel extends SurveyElementCore private isLockingUpdateOnPageModes: boolean; private setupPagesForPageModes(isSinglePage: boolean, isFirstLoad: boolean) { this.questionHashesClear(); + if(!isSinglePage && this.firstPageIsStarted && this.pages.length > 0) { + this.pages[0].questions.forEach(q => this.questionHashesAdded(q)); + } this.isLockingUpdateOnPageModes = !isFirstLoad; var startIndex = this.getPageStartIndex(); super.startLoadingFromJson(); diff --git a/tests/surveytests.ts b/tests/surveytests.ts index 764fccc6ed..a0a1a56a68 100644 --- a/tests/surveytests.ts +++ b/tests/surveytests.ts @@ -20247,4 +20247,25 @@ 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"); }); \ No newline at end of file