Skip to content

Commit

Permalink
questionsOnPageMode: questionPerPage & complete trigger & required …
Browse files Browse the repository at this point in the history
…questions on the same page, fix Bug#9289 (#9290)
  • Loading branch information
andrewtelnov authored Jan 10, 2025
1 parent 71634db commit c89a5f4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/survey-core/src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4331,10 +4331,15 @@ export class SurveyModel extends SurveyElementCore
isFocuseOnFirstError: boolean = undefined
): boolean {
if (isFocuseOnFirstError === undefined) {
isFocuseOnFirstError = this.autoFocusFirstError;
isFocuseOnFirstError = this.focusOnFirstError;
}
if (!page) return true;
var res = !page.validate(true, isFocuseOnFirstError);
let res: boolean = false;
if(this.currentSingleQuestion) {
res = !this.currentSingleQuestion.validate(true);
} else {
res = !page.validate(true, isFocuseOnFirstError);
}
this.fireValidatedErrorsOnPage(page);
return res;
}
Expand Down
23 changes: 23 additions & 0 deletions packages/survey-core/tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20772,6 +20772,29 @@ QUnit.test("Question is not in the hash with it is on the first page & questions
const q = survey.getQuestionByName("q1");
assert.equal(q.name, "q1", "q1 name is here");
});
QUnit.test("questionsOnPageMode: `questionPerPage` & complete trigger & required questions on the same page, Bug#9289", function (assert) {
const survey = new SurveyModel({
"elements": [
{ "type": "text", "name": "q1", "isRequired": true },
{ "type": "text", "name": "q2", "isRequired": true }
],
"questionsOnPageMode": "questionPerPage",
"triggers": [
{
"type": "complete",
"expression": "{q1} = 'a'"
}
]
});
const btnComplete = survey.navigationBar.getActionById("sv-nav-complete");
assert.equal(btnComplete.visible, false, "Complete button is visible, #1");
assert.equal(survey.currentSingleQuestion.name, "q1", "currentSingleQuestion");
survey.currentSingleQuestion.value = "a";
assert.equal(btnComplete.visible, true, "Complete button is visible, #2");
assert.equal(survey.state, "running", "Survey is running");
btnComplete.action();
assert.equal(survey.state, "completed", "Survey is completed");
});
QUnit.test("Do not use questionsOnPageMode in design-mode, Bug#9274", function (assert) {
const json = {
"pages": [{
Expand Down

0 comments on commit c89a5f4

Please sign in to comment.