Skip to content

Commit

Permalink
Only insert one toggle-content button. Insert a skip link on the firs…
Browse files Browse the repository at this point in the history
…t sideMenuPart. Update invocation of `ensureNavButtonInteractable` function.
  • Loading branch information
lauzadis committed Jul 10, 2024
1 parent 2f5aa38 commit e48985a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docs/dokka-presets/scripts/accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function applySkipLinks() {
document.querySelectorAll('.sideMenuPart[data-active]').forEach(function(sideMenuPart) {
insertSkipLink(sideMenuPart)
});

// Insert a skip link on the first sideMenuPart
const firstSideMenuPart = document.getElementById("sideMenu").children[0].querySelectorAll(".sideMenuPart")[0]
insertSkipLink(firstSideMenuPart)
}

const observer = new MutationObserver(handleChanges);
Expand Down Expand Up @@ -86,11 +90,9 @@ function ensureNavButtonInteractable() {
});
}

window.onload = function() {
ensureNavButtonInteractable()
}
document.addEventListener('DOMContentLoaded', ensureNavButtonInteractable)
if (document.readyState === "interactive" || document.readyState === "complete" ) { ensureNavButtonInteractable() }

//
/**
* Ensure that content (specifically, code blocks) reflows on small page sizes.
* Fixes accessibility violation: "Ensure pages reflow without requiring two-dimensional scrolling without loss of content or functionality"
Expand All @@ -100,6 +102,8 @@ function ensureContentReflow() {

// Function to insert 'toggle content' button
function insertToggleContentButton(element) {
if (element.parentNode.querySelectorAll(".aws-toggle-content-btn").length > 0) { return }

const initiallyVisible = window.innerWidth >= MIN_WINDOW_SIZE

const toggleContent = document.createElement('button');
Expand Down

0 comments on commit e48985a

Please sign in to comment.