Skip to content

Commit

Permalink
Fix "Ensure custom controls provide proper textual name, role, and st…
Browse files Browse the repository at this point in the history
…ate information"
  • Loading branch information
lauzadis committed Jul 1, 2024
1 parent ed7555d commit ad984ba
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/dokka-presets/templates/base.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@
navButton.setAttribute('role', 'button');
navButton.setAttribute('aria-expanded', 'false');
// Grab the grandparent element's page ID, use it for aria-label and aria-controls
const sectionName = navButton.parentElement.parentElement.getAttribute('pageid')
// Remove the page ID suffix auto-generated by Dokka
const cleanedSectionName = sectionName.substring(0, sectionName.indexOf("////PointingToDeclaration"))
navButton.setAttribute('aria-label', cleanedSectionName);
const sectionID = navButton.parentElement.parentElement.id
navButton.setAttribute('aria-controls', sectionID);
// Add event listener for Enter and Space keys
navButton.addEventListener('keydown', function(event) {
if (event.key === 'Enter' || event.key === ' ') {
Expand Down

0 comments on commit ad984ba

Please sign in to comment.