Skip to content

Commit 96c752e

Browse files
authored
misc: docs accessibility fixes (#1356)
1 parent 17fc951 commit 96c752e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/dokka-presets/scripts/accessibility.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ function applySkipLinks() {
3333
document.querySelectorAll('.sideMenuPart[data-active]').forEach(function(sideMenuPart) {
3434
insertSkipLink(sideMenuPart)
3535
});
36+
37+
// Insert a skip link on the first sideMenuPart
38+
const firstSideMenuPart = document.getElementById("sideMenu").children[0].querySelectorAll(".sideMenuPart")[0]
39+
insertSkipLink(firstSideMenuPart)
3640
}
3741

3842
const observer = new MutationObserver(handleChanges);
@@ -86,9 +90,8 @@ function ensureNavButtonInteractable() {
8690
});
8791
}
8892

89-
window.onload = function() {
90-
ensureNavButtonInteractable()
91-
}
93+
document.addEventListener('DOMContentLoaded', ensureNavButtonInteractable)
94+
if (document.readyState === "interactive" || document.readyState === "complete" ) { ensureNavButtonInteractable() }
9295

9396
/**
9497
* Ensure that content (specifically, code blocks) reflows on small page sizes.
@@ -99,6 +102,8 @@ function ensureContentReflow() {
99102

100103
// Function to insert 'toggle content' button
101104
function insertToggleContentButton(element) {
105+
if (element.parentNode.querySelectorAll(".aws-toggle-content-btn").length > 0) { return }
106+
102107
const initiallyVisible = window.innerWidth >= MIN_WINDOW_SIZE
103108

104109
const toggleContent = document.createElement('button');

0 commit comments

Comments
 (0)