Skip to content

Commit

Permalink
ModalDialog: focus first tabbable element when focus leaves dialog #1689
Browse files Browse the repository at this point in the history


(cherry picked from commit f76e0bc)
  • Loading branch information
ashklianko authored and alansemenov committed Jan 7, 2021
1 parent 4062473 commit 91ff1b1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export abstract class ModalDialog
// last focusable - Cancel
// first focusable - X
if (buttonRowIsFocused) { // last element lost focus
this.tabbable[0].giveFocus();
this.focusFirstTabbable();
} else {
this.tabbable[this.tabbable.length - 1].giveFocus();
}
Expand All @@ -271,6 +271,12 @@ export abstract class ModalDialog
return false;
}

protected focusFirstTabbable() {
this.tabbable.some((el: Element) => {
return el.giveFocus();
});
}

private createResizeObserver() {
if (window['ResizeObserver']) {
this.resizeObserver = new window['ResizeObserver'](() => {
Expand Down

0 comments on commit 91ff1b1

Please sign in to comment.