Skip to content

Commit 9d1aae3

Browse files
committed
refactor(overlays): check for mode
1 parent 8a7db47 commit 9d1aae3

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

core/src/utils/overlays.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ export const present = async <OverlayPresentOptions>(
524524
document.body.classList.add(BACKDROP_NO_SCROLL);
525525

526526
hideUnderlyingOverlaysFromScreenReaders(overlay.el);
527+
hideAnimatingOverlayFromScreenReaders(overlay.el);
527528

528529
overlay.presented = true;
529530
overlay.willPresent.emit();
@@ -535,8 +536,6 @@ export const present = async <OverlayPresentOptions>(
535536
? overlay.enterAnimation
536537
: config.get(name, mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
537538

538-
// hideAnimatingOverlayFromScreenReaders(overlay.el);
539-
540539
const completed = await overlayAnimation(overlay, animationBuilder, overlay.el, opts);
541540
if (completed) {
542541
overlay.didPresent.emit();
@@ -752,26 +751,14 @@ const overlayAnimation = async (
752751
animation.duration(0);
753752
}
754753

755-
animation.beforeAddWrite(() => {
756-
console.log('beforeAddWrite');
757-
baseEl.setAttribute('aria-hidden', 'true');
758-
// add class 'test' to baseEl
759-
baseEl.classList.add('test');
760-
761-
if (overlay.keyboardClose) {
754+
if (overlay.keyboardClose) {
755+
animation.beforeAddWrite(() => {
762756
const activeElement = baseEl.ownerDocument!.activeElement as HTMLElement;
763757
if (activeElement?.matches('input,ion-input, ion-textarea')) {
764758
activeElement.blur();
765759
}
766-
}
767-
});
768-
769-
animation.afterAddWrite(() => {
770-
baseEl.removeAttribute('aria-hidden');
771-
// add test2 class to baseEl
772-
baseEl.classList.add('test2');
773-
console.log('afterAddWrite');
774-
});
760+
});
761+
}
775762

776763
const activeAni = activeAnimations.get(overlay) || [];
777764
activeAnimations.set(overlay, [...activeAni, animation]);
@@ -986,18 +973,28 @@ export const createTriggerController = () => {
986973
* If the overlay is being presented, it prevents focus rings from appearing
987974
* in incorrect positions due to the transition (specifically `transform`
988975
* styles), ensuring that when aria-hidden is removed, the focus rings are
989-
* correctly displayed in the final location of the elements.
976+
* correctly displayed in the final location of the elements. This only
977+
* applies to Android devices.
978+
*
979+
* If this solution is applied to iOS devices, then it leads to a bug where
980+
* the overlays cannot be accessed by screen readers. This is due to
981+
* VoiceOver not being able to update the accessibility tree when the
982+
* `aria-hidden` is removed.
990983
*
991984
* @param overlay - The overlay that is being animated.
992985
*/
993986
const hideAnimatingOverlayFromScreenReaders = (overlay: HTMLIonOverlayElement) => {
994987
if (doc === undefined) return;
995988

996-
/**
997-
* Once the animation is complete, this attribute will be removed.
998-
* This is done at the end of the `present` method.
999-
*/
1000-
overlay.setAttribute('aria-hidden', 'true');
989+
const mode = getIonMode(overlay);
990+
991+
if (mode === 'md') {
992+
/**
993+
* Once the animation is complete, this attribute will be removed.
994+
* This is done at the end of the `present` method.
995+
*/
996+
overlay.setAttribute('aria-hidden', 'true');
997+
}
1001998
};
1002999

10031000
/**

0 commit comments

Comments
 (0)