Skip to content

Commit

Permalink
Merge pull request #8866 from surveyjs/bug/8847-toc-show-page-numbers
Browse files Browse the repository at this point in the history
Fixed #8847 - Table Of Contents - Page numbers are missing
  • Loading branch information
andrewtelnov authored Sep 30, 2024
2 parents 443a946 + fbbb945 commit 994f0fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/survey-core/src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export class PageModel extends PanelModelBase implements IPage {
this.locNavigationTitle.strChanged();
this.locNavigationDescription.strChanged();
}
getMarkdownHtml(text: string, name: string): string {
const result = super.getMarkdownHtml(text, name);
if (name === "navigationTitle" && this.canShowPageNumber() && result) {
return this.num + ". " + result;
}
return result;
}
public get passed(): boolean {
return this.getPropertyValue("passed", false);
}
Expand Down
17 changes: 17 additions & 0 deletions packages/survey-core/tests/surveyTOCTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,20 @@ QUnit.test("update toc list model on add new page and add new question", functio
assert.equal(tocListModel.actions[1].visible, true);
assert.equal(tocListModel.actions[1].title, "New Page");
});

QUnit.test("TOC navigation shows page numbers", function (assert) {
const survey = new SurveyModel({
showTOC: true,
showPageNumbers: true,
pages: [{
name: "page1",
elements: [
{ type: "text", name: "q1" },
]
}]
});
const tocListModel = createTOCListModel(survey);
assert.equal(tocListModel.actions.length, 1);
assert.equal(tocListModel.actions[0].visible, true);
assert.equal(tocListModel.actions[0].title, "1. page1");
});

0 comments on commit 994f0fb

Please sign in to comment.