Skip to content

OEL-4981: Accessible semantics for offcanvas. - #622

Open
tibi2303 wants to merge 5 commits into
1.xfrom
OEL-4981
Open

OEL-4981: Accessible semantics for offcanvas.#622
tibi2303 wants to merge 5 commits into
1.xfrom
OEL-4981

Conversation

@tibi2303

Copy link
Copy Markdown
Contributor

Jira issue(s):

@tibi2303 tibi2303 linked an issue Aug 19, 2026 that may be closed by this pull request
Comment on lines +25 to +40
document
.querySelectorAll('[class*="offcanvas-"][role]')
.forEach(function initializeStaticOffcanvasRole(offcanvas) {
if (staticOffcanvasRoles.has(offcanvas)) {
return;
}

staticOffcanvasRoles.set(offcanvas, offcanvas.getAttribute('role'));
// Bootstrap removes its dialog role when the offcanvas closes.
offcanvas.addEventListener(
'hidden.bs.offcanvas',
function restoreStaticOffcanvasRole() {
offcanvas.setAttribute('role', staticOffcanvasRoles.get(offcanvas));
}
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new WeakMap stores the current role from the live DOM, which can already be dialog if this behavior attaches after Bootstrap has opened the offcanvas. In that case we restore the wrong role on close. Please cache the intended static role from an author controlled source instead, for example a data-* attribute set in Twig, and restore from that value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed, indeed. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility: Offcanvas semantics for aria-labelledby

2 participants