Skip to content

Commit 3014945

Browse files
authored
fix: enhance accessibility for sidebar toggle button (#2604)
1 parent 1ad5763 commit 3014945

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/core/event/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,11 @@ export function Events(Base) {
548548

549549
// Set aria-expanded attribute
550550
ariaElms.forEach(toggleElm => {
551+
const expanded = force ?? sidebarElm.classList.contains('show');
552+
toggleElm.setAttribute('aria-expanded', expanded);
551553
toggleElm.setAttribute(
552-
'aria-expanded',
553-
force ?? sidebarElm.classList.contains('show'),
554+
'aria-label',
555+
expanded ? 'Hide primary navigation' : 'Show primary navigation',
554556
);
555557
});
556558

src/core/render/tpl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function main(config) {
4343
? ''
4444
: `
4545
<button class="sidebar-toggle" tabindex="-1" title="Press \\ to toggle">
46-
<div class="sidebar-toggle-button" tabindex="0" aria-label="Toggle primary navigation" aria-keyshortcuts="\\" aria-controls="__sidebar">
46+
<div class="sidebar-toggle-button" tabindex="0" aria-label="Hide primary navigation" aria-keyshortcuts="Use shortcut key \\" aria-controls="__sidebar" role="button">
4747
<span></span><span></span><span></span>
4848
</div>
4949
</button>

0 commit comments

Comments
 (0)