Skip to content

Commit

Permalink
fix disclosure focus
Browse files Browse the repository at this point in the history
  • Loading branch information
basher committed Apr 2, 2024
1 parent 7d2abfa commit 3a73486
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ui/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions ui/src/javascript/web-components/webui-disclosure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@ export default class WebUIDisclosure extends HTMLElement {
return random;
}

private hideContent(): void {
private hideContent(e?: KeyboardEvent): void {
if (this.trigger?.getAttribute('aria-expanded') === 'true') {
// Set keyboard :FOCUS on the trigger button.
this.trigger?.focus();
this.trigger?.setAttribute('aria-expanded', 'false');
this.content?.setAttribute('hidden', '');

// Set keyboard :FOCUS on the trigger button.
if (e?.type === 'keyup') {
this.trigger?.focus();
}
}
this.content?.setAttribute('hidden', '');
}

private handleGlobalKeyup(e: KeyboardEvent): void {
if (this.bindEscapeKey && e.code === 'Escape') {
this.hideContent();
this.hideContent(e);
}
}

Expand Down

0 comments on commit 3a73486

Please sign in to comment.