Addressed feedback

This commit is contained in:
saberzero1 2024-10-03 19:54:31 +02:00
parent 4e8e251f32
commit 0513ad4d15
No known key found for this signature in database
GPG Key ID: 41AEE99107640F10
2 changed files with 15 additions and 2 deletions

View File

@ -100,6 +100,8 @@ export default ((userOpts?: Partial<Options>) => {
data-pagepathstate={opts.usePagePath}
data-tree={jsonTree}
data-mobile={true}
aria-controls="explorer-content"
aria-expanded={false}
>
<svg
xmlns="http://www.w3.org/2000/svg"
@ -126,6 +128,8 @@ export default ((userOpts?: Partial<Options>) => {
data-pagepathstate={opts.usePagePath}
data-tree={jsonTree}
data-mobile={false}
aria-controls="explorer-content"
aria-expanded={true}
>
<h2>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h2>
<svg

View File

@ -54,6 +54,13 @@ function toggleFolder(evt: MouseEvent) {
function toggleExplorer(this: HTMLElement) {
// Toggle collapsed state of entire explorer
this.classList.toggle("collapsed")
// Toggle collapsed aria state of entire explorer
this.setAttribute(
"aria-expanded",
this.getAttribute("aria-expanded") === "true" ? "false" : "true",
)
const content = (
this.nextElementSibling?.nextElementSibling
? this.nextElementSibling.nextElementSibling
@ -120,7 +127,10 @@ function setupExplorer() {
currentExplorerState = []
for (const { path, collapsed } of newExplorerState) {
currentExplorerState.push({ path, collapsed: usePagePathState ? oldIndex.get(path) ?? collapsed : collapsed })
currentExplorerState.push({
path,
collapsed: usePagePathState ? (oldIndex.get(path) ?? collapsed) : collapsed,
})
}
currentExplorerState.map((folderState) => {
@ -166,7 +176,6 @@ document.addEventListener("nav", () => {
}
}
setupExplorer()
//add collapsed class to all folders
observer.disconnect()