From e34e4728d010fed4aac784a34785e99170f0ebce Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Fri, 21 May 2021 06:52:44 +1000 Subject: [PATCH] Fix accessibility (a11y) on swal2 modals (#986) * Remove tabindex on bootstrap modals if swal open * fix linting --- src/services/webPlatformUtils.service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/services/webPlatformUtils.service.ts b/src/services/webPlatformUtils.service.ts index c87eeb2f102..3f17b9874a8 100644 --- a/src/services/webPlatformUtils.service.ts +++ b/src/services/webPlatformUtils.service.ts @@ -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 ? `` : 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; }