Fix accessibility (a11y) on swal2 modals (#986)

* Remove tabindex on bootstrap modals if swal open

* fix linting
This commit is contained in:
Thomas Rittson 2021-05-21 06:52:44 +10:00 committed by GitHub
parent 35346613d8
commit e34e4728d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -195,6 +195,11 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
}
}
const bootstrapModal = document.querySelector('div.modal');
if (bootstrapModal != null) {
bootstrapModal.removeAttribute('tabindex');
}
const iconHtmlStr = iconClasses != null ? `<i class="swal-custom-icon fa ${iconClasses}"></i>` : undefined;
const confirmed = await Swal.fire({
heightAuto: false,
@ -210,6 +215,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
confirmButtonText: confirmText == null ? this.i18nService.t('ok') : confirmText,
});
if (bootstrapModal != null) {
bootstrapModal.setAttribute('tabindex', '-1');
}
return confirmed.value;
}