Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion assets/js/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,24 @@ function setupShortcuts(shortcutDepth = 2) {

shortcutDepth += 1; // to account for the page title

// Build a class selector for each header type, and concatenate with commas
/*
* We have build selectors to find headers in different contexts.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* We have build selectors to find headers in different contexts.
* We build selectors to find headers in different contexts.

* i. direct children of .content-container (main structure)
* i. headers within tabpanels (for tabbed content)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these were the ones we explicitly avoided before? We don't want to link to the content of tabpanels!

*/
let classes = "";

for (let i = 2; i <= shortcutDepth; i++) {
if (i != 2) {
classes += ",";
}
classes += " .content-container > h" + i;
}

for (let i = 2; i <= shortcutDepth; i++) {
classes += ", [role='tabpanel'] > h" + i;
}

const classElements = Array.from(document.querySelectorAll(classes));

// Only proceed if we found headers (to avoid creating an empty shortcuts section)
Expand Down