mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
Fixes for dynamic modal a11y (#518)
* Do not close modal if click finishes on background * Trap tab focus in modals, use ESC to close modal * Fix Angular change detection errors in modals * Reset focus on next modal after closing modal * Minor fixes and linting * Attach focusTrap to modal-dialog element * Change mousedown event back to click * Make topModal private * Add new div for dismissing modal by clicking bg * Focus element in modal if no autoFocus directive * Use backdrop for dismissal * Fix typo
This commit is contained in:
@@ -2,8 +2,11 @@ import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
Input,
|
||||
NgZone,
|
||||
} from '@angular/core';
|
||||
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { Utils } from 'jslib-common/misc/utils';
|
||||
|
||||
@Directive({
|
||||
@@ -16,11 +19,15 @@ export class AutofocusDirective {
|
||||
|
||||
private autofocus: boolean;
|
||||
|
||||
constructor(private el: ElementRef) { }
|
||||
constructor(private el: ElementRef, private ngZone: NgZone) { }
|
||||
|
||||
ngOnInit() {
|
||||
if (!Utils.isMobileBrowser && this.autofocus) {
|
||||
this.el.nativeElement.focus();
|
||||
if (this.ngZone.isStable) {
|
||||
this.el.nativeElement.focus();
|
||||
} else {
|
||||
this.ngZone.onStable.pipe(take(1)).subscribe(() => this.el.nativeElement.focus());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user