Skip to content

Commit

Permalink
fix aria-controls for web components
Browse files Browse the repository at this point in the history
  • Loading branch information
basher committed Apr 2, 2024
1 parent cf0ebcc commit 776084a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/src/javascript/utils/disclosure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const disclosure = (arg: Disclosure): void => {

// Auto-generate unique 'id' and 'aria-controls' attributes, using button 'parentElement' classname as a sensible prefix.
if (arg.button.parentElement) {
const unique = randomString(arg.button.parentElement.classList[0]);
const unique = randomString(
arg.button.parentElement.classList[0] ||
arg.button.parentElement.nodeName.toLowerCase(),
);
arg.content?.setAttribute('id', unique);
arg.button.setAttribute('aria-controls', unique);
}
Expand Down

0 comments on commit 776084a

Please sign in to comment.