Skip to content

Commit

Permalink
The Table of Content ignores the survey.validationEnabled = false opt…
Browse files Browse the repository at this point in the history
…ion fix #9363
  • Loading branch information
andrewtelnov committed Jan 29, 2025
1 parent 2e73181 commit bd999e8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/survey-core/src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3575,6 +3575,7 @@ export class SurveyModel extends SurveyElementCore
}
private performValidationOnPageChanging(page: PageModel): boolean {
if (this.isDesignMode) return false;
if(this.canGoTroughValidation()) return true;
const index = this.visiblePages.indexOf(page);
if (index < 0 || index >= this.visiblePageCount) return false;
if (index === this.currentPageNo) return false;
Expand Down Expand Up @@ -4112,7 +4113,7 @@ export class SurveyModel extends SurveyElementCore
return true;
}
private hasErrorsOnNavigate(doComplete: boolean): boolean {
if (!this.isEditMode || this.ignoreValidation) return false;
if (this.canGoTroughValidation()) return false;
const skipValidation = doComplete && this.validationAllowComplete || !doComplete && this.validationAllowSwitchPages;
const func = (hasErrors: boolean) => {
if (!hasErrors || skipValidation) {
Expand All @@ -4125,6 +4126,7 @@ export class SurveyModel extends SurveyElementCore
}
return this.validateCurrentPage(func) !== true && !skipValidation;
}
private canGoTroughValidation(): boolean { return !this.isEditMode || !this.validationEnabled; }
private asyncValidationQuesitons: Array<Question>;
private checkForAsyncQuestionValidation(
questions: Array<Question>,
Expand Down
41 changes: 41 additions & 0 deletions packages/survey-core/tests/surveyTOCTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,47 @@ QUnit.test("survey.tryNavigateToPage & survey.onValidatedErrorsOnCurrentPage, Bu
assert.equal(survey.tryNavigateToPage(survey.pages[0]), true, "try #8");
assert.deepEqual(logs, ["page1", "page1", "page1", "page2", "page2"], "logs #8");
});
QUnit.test("survey.tryNavigateToPage & survey.validationEnabled = false, Bug#9363", function (assert) {
let json: any = {
"pages": [
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question1",
"isRequired": true
}
]
},
{
"name": "page2",
"elements": [
{
"type": "text",
"name": "question2",
"isRequired": true
}
]
},
{
"name": "page3",
"elements": [
{
"type": "text",
"name": "question3",
"isRequired": true
}
]
}
]
};
const survey = new SurveyModel(json);
const logs = new Array<string>();
assert.equal(survey.tryNavigateToPage(survey.pages[1]), false, "try #1");
survey.validationEnabled = false;
assert.equal(survey.tryNavigateToPage(survey.pages[1]), true, "try #2");
});
QUnit.test("The survey.onServerValidateQuestions function is not invoked when a user navigates between pages using the progress bar #9332", function (assert) {
const survey = new SurveyModel({
"pages": [
Expand Down

0 comments on commit bd999e8

Please sign in to comment.