From 56252ab782cb9cacb3ad181641ed605eeeaf8826 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 9 Jan 2025 08:50:22 +0000 Subject: [PATCH] "questionsOnPageMode": "questionPerPage" doesn't work correctly with skip trigger fix #9276 (#9277) --- packages/survey-core/src/survey.ts | 3 +++ packages/survey-core/tests/surveytests.ts | 30 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/packages/survey-core/src/survey.ts b/packages/survey-core/src/survey.ts index 4b5573eb5e..36591572fb 100644 --- a/packages/survey-core/src/survey.ts +++ b/packages/survey-core/src/survey.ts @@ -7933,6 +7933,9 @@ export class SurveyModel extends SurveyElementCore const isNeedWaitForPageRendered = this.activePage !== question.page && !question.page.isStartPage; if (isNeedWaitForPageRendered) { this.currentPage = question.page; + if(this.isSingleVisibleQuestion && !this.isDesignMode) { + this.currentSingleQuestion = question; + } } if (!isNeedWaitForPageRendered) { this.focusQuestionInfo(); diff --git a/packages/survey-core/tests/surveytests.ts b/packages/survey-core/tests/surveytests.ts index dcbf31d10f..2a926e9217 100644 --- a/packages/survey-core/tests/surveytests.ts +++ b/packages/survey-core/tests/surveytests.ts @@ -19498,6 +19498,36 @@ QUnit.test("survey.toJSON() doesn't work correctly if questionsOnPageMode=questi assert.deepEqual(surveyJson, prepareJSON); }); +QUnit.test("questionsOnPageMode=questionPerPage & skip doesn't work correctly, Bug #9276", function (assert) { + const surveyJson = { + "questionsOnPageMode": "questionPerPage", + "pages": [ + { + "elements": [ + { "type": "text", "name": "q1" }, + { "type": "text", "name": "q2" } + ] + }, + { + "elements": [ + { "type": "text", "name": "q3" }, + { "type": "text", "name": "q4" } + ] + } + ], + "triggers": [ + { + "type": "skip", + "expression": "{q1} = 'a'", + "gotoName": "q4" + }] + }; + + const survey = new SurveyModel(surveyJson); + assert.equal(survey.currentSingleQuestion.name, "q1", "#1"); + survey.currentSingleQuestion.value = "a"; + assert.equal(survey.currentSingleQuestion.name, "q4", "#2"); +}); QUnit.test("defaultValue & visibleIf issues if questionsOnPageMode=questionPerPage is used #7932", function (assert) { const surveyJson = { elements: [