Skip to content

Commit

Permalink
fix(modal): no focusable element on open
Browse files Browse the repository at this point in the history
  • Loading branch information
balsigergil committed Jan 21, 2024
1 parent 0a0f091 commit 55b5b0e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/modal/Modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export class Modal extends HTMLElement {
const focusableElements = this.querySelectorAll<HTMLElement>(
"a, button, input, textarea, select, details, [tabindex]:not([tabindex='-1'])",
);
if (focusableElements.length === 0) {
return;
}
const first = focusableElements[0];
first.focus();
}
Expand Down

0 comments on commit 55b5b0e

Please sign in to comment.