Skip to content

Commit

Permalink
Fixed surveyjs#7415 - Introduce an option to disable the search bar w…
Browse files Browse the repository at this point in the history
…ithin Table Of Contents
  • Loading branch information
tsv2013 committed Dec 1, 2023
1 parent 69f096f commit 83d176f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/surveyToc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function createTOCListModel(survey: SurveyModel, onAction?: () => void) {
);
listModel.allowSelection = false;
listModel.locOwner = survey;
listModel.searchEnabled = false;
survey.onCurrentPageChanged.add((s, o) => {
listModel.selectedItem = items.filter(i => i.id === survey.currentPage.name)[0];
});
Expand Down
21 changes: 20 additions & 1 deletion tests/surveyTOCTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,23 @@ QUnit.test("TOC shouldn't affect page title", function (assert) {
assert.equal(tocListModel.visibleItems.length, 1, "2 items is TOC");
assert.equal(tocListModel.visibleItems[0].locTitle.textOrHtml, "Text with <em>emphasys text</em>", "Page 1 - nav title in TOC");
assert.equal(page.locTitle.textOrHtml, "Page 1 title", "Page 1 title");
});
});

QUnit.test("TOC shouldn't show search", function (assert) {
let json: any = {
"pages": [
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question2"
}
]
},
]
};
const survey: SurveyModel = new SurveyModel(json);
const tocListModel = createTOCListModel(survey);
assert.equal(tocListModel.searchEnabled, false, "Search in TOC should be disabled");
});

0 comments on commit 83d176f

Please sign in to comment.