fix(a11y): clear stale aria-expanded when switching panels (#6656)

_syncSidebarAria set aria-expanded on the newly-active rail button without
unsetting the previous one, so chat -> kanban -> skills left three buttons all
claiming aria-expanded=true. A screen reader announced three open disclosures
when only one panel owns the sidebar.

Reset every rail button that carries the attribute before setting the active
one.
This commit is contained in:
Rodrigo Gomes da Silva authored and GitHub committed 2026-08-09 21:44:58 +00:00
1 parent 192df903c8
commit 70c77095a7
1 file changed
+6
+6
View File
@@ -529,6 +529,12 @@ function _isSidebarCollapsed(){
function _syncSidebarAria(){
// Mirror the open/collapsed state on the active rail button via aria-expanded
// so screen readers announce the toggle. Open=true, collapsed=false.
// Clear the others first: only one panel owns the sidebar, but this used to set
// aria-expanded on the newly-active button without unsetting the previous one,
// so chat -> kanban -> skills left three buttons claiming aria-expanded=true
// and a screen reader announced three open disclosures.
document.querySelectorAll('.rail .rail-btn.nav-tab[data-panel][aria-expanded]')
.forEach(function(btn){ btn.setAttribute('aria-expanded','false'); });
const active=document.querySelector('.rail .rail-btn.nav-tab.active[data-panel]');
if(active)active.setAttribute('aria-expanded',!_isSidebarCollapsed());
}