Skip to content

Commit

Permalink
survey.tryNavigateToPage doesn't work correctly if checkErrorsMode is…
Browse files Browse the repository at this point in the history
… "onComplete" fix #7683 (#7684)
  • Loading branch information
andrewtelnov authored Jan 16, 2024
1 parent 704242f commit 34effef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3144,9 +3144,9 @@ export class SurveyModel extends SurveyElementCore
public tryNavigateToPage(page: PageModel): boolean {
if (this.isDesignMode) return false;
const index = this.visiblePages.indexOf(page);
if (index < 0) return false;
if (index < 0 || index >= this.visiblePageCount) return false;
if (index === this.currentPageNo) return false;
if (index < this.currentPageNo) {
if (index < this.currentPageNo || this.isValidateOnComplete) {
this.currentPageNo = index;
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/surveyTOCTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@ QUnit.test("survey.tryNavigateToPage", function (assert) {
assert.equal(survey.tryNavigateToPage(survey.pages[3]), true, "navigate #6");
assert.equal(survey.currentPageNo, 3, "currentPageNo #6");
assert.deepEqual(pages, ["page2", "page1", "page3", "page1", "page4"], "Check onCurrentPageChanged");

survey.clear();
assert.equal(survey.currentPageNo, 0, "currentPageNo #7");
assert.equal(survey.tryNavigateToPage(survey.pages[3]), false, "navigate #7");
survey.checkErrorsMode = "onComplete";
assert.equal(survey.tryNavigateToPage(survey.pages[3]), true, "navigate #8");
assert.equal(survey.currentPageNo, 3, "currentPageNo #9");
});
QUnit.test("TOC should be created for survey with no current page", function (assert) {
let json: any = { "logoPosition": "right", "pages": [{ "name": "page1", "elements": [{ "type": "panel", "name": "panel1", "width": "1180px" }] }] };
Expand Down

0 comments on commit 34effef

Please sign in to comment.