Skip to content

Commit

Permalink
NOJIRA: provide a label for toc container
Browse files Browse the repository at this point in the history
  • Loading branch information
jobara committed Jul 31, 2024
1 parent 971b820 commit c6c6e7b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/tableOfContents/js/TableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ fluid.defaults("fluid.tableOfContents", {
}
},
listeners: {
"onCreate.setLabel": {
"this": "{that}.dom.tocContainer",
"method": "attr",
"args": ["aria-label", "{that}.options.strings.tocHeader"],
"priority": "before:refreshView"
},
"onCreate.refreshView": {
func: "{that}.refreshView",
// New for FLUID-6148: Make sure we do not try to refresh view until after "levels" subcomponent is constructed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,10 @@ <h2 class="fluid-5697-exclude">Excluded</h2>
<h3>Excluded</h3>
</section>
</div>

<div id="flc-toc-nav-label">
<nav class="flc-toc-tocContainer toc"></nav>
<h2>Nav Label Test</h2>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions tests/component-tests/tableOfContents/js/TableOfContentsTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,3 +610,21 @@ jqUnit.asyncTest("FLUID-5697: Header exclusion", function () {
}
});
});


jqUnit.asyncTest("Table of Contents nav label", function () {
fluid.tableOfContents("#flc-toc-nav-label", {
strings: {
tocHeader: "Test ToC label"
},
listeners: {
onReady: {
listener: function (that) {
jqUnit.assertEquals("The toc container should have an aria-label", that.options.strings.tocHeader, that.locate("tocContainer").attr("aria-label"));
jqUnit.start();
},
args: ["{that}"]
}
}
});
});

0 comments on commit c6c6e7b

Please sign in to comment.