Skip to content

Commit 8a7db47

Browse files
committed
refactor(overlays): verify baseEl
1 parent f8e620f commit 8a7db47

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

core/src/utils/overlays.ts

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

526526
hideUnderlyingOverlaysFromScreenReaders(overlay.el);
527-
hideAnimatingOverlayFromScreenReaders(overlay.el);
528527

529528
overlay.presented = true;
530529
overlay.willPresent.emit();
@@ -536,6 +535,8 @@ export const present = async <OverlayPresentOptions>(
536535
? overlay.enterAnimation
537536
: config.get(name, mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
538537

538+
// hideAnimatingOverlayFromScreenReaders(overlay.el);
539+
539540
const completed = await overlayAnimation(overlay, animationBuilder, overlay.el, opts);
540541
if (completed) {
541542
overlay.didPresent.emit();
@@ -751,14 +752,26 @@ const overlayAnimation = async (
751752
animation.duration(0);
752753
}
753754

754-
if (overlay.keyboardClose) {
755-
animation.beforeAddWrite(() => {
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) {
756762
const activeElement = baseEl.ownerDocument!.activeElement as HTMLElement;
757763
if (activeElement?.matches('input,ion-input, ion-textarea')) {
758764
activeElement.blur();
759765
}
760-
});
761-
}
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+
});
762775

763776
const activeAni = activeAnimations.get(overlay) || [];
764777
activeAnimations.set(overlay, [...activeAni, animation]);
@@ -980,17 +993,11 @@ export const createTriggerController = () => {
980993
const hideAnimatingOverlayFromScreenReaders = (overlay: HTMLIonOverlayElement) => {
981994
if (doc === undefined) return;
982995

983-
const mode = getIonMode(overlay);
984-
console.log('mode', mode);
985-
986-
if (mode === 'md') {
987-
console.log('in md');
988-
/**
989-
* Once the animation is complete, this attribute will be removed.
990-
* This is done at the end of the `present` method.
991-
*/
992-
overlay.setAttribute('aria-hidden', 'true');
993-
}
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');
9941001
};
9951002

9961003
/**

0 commit comments

Comments
 (0)