MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / afterAnimation

Method afterAnimation

core/src/components/menu/menu.tsx:722–796  ·  view source on GitHub ↗
(isOpen: boolean, role?: string)

Source from the content-addressed store, hash-verified

720 }
721
722 private afterAnimation(isOpen: boolean, role?: string) {
723 // keep opening/closing the menu disabled for a touch more yet
724 // only add listeners/css if it's enabled and isOpen
725 // and only remove listeners/css if it's not open
726 // emit opened/closed events
727 this._isOpen = isOpen;
728 this.isAnimating = false;
729 if (!this._isOpen) {
730 this.blocker.unblock();
731 }
732
733 if (isOpen) {
734 /**
735 * When the menu is presented on an Android device, TalkBack's focus rings
736 * may appear in the wrong position due to the transition (specifically
737 * `transform` styles). The menu is hidden from screen readers during the
738 * transition to prevent this. Once the transition is complete, the menu
739 * is shown again.
740 */
741 if (isPlatform('android')) {
742 this.el.removeAttribute('aria-hidden');
743 }
744
745 // emit open event
746 this.ionDidOpen.emit();
747
748 /**
749 * Move focus to the menu to prepare focus trapping, as long as
750 * it isn't already focused. Use the host element instead of the
751 * first descendant to avoid the scroll position jumping around.
752 */
753 const focusedMenu = document.activeElement?.closest('ion-menu');
754 if (focusedMenu !== this.el) {
755 this.el.focus();
756 }
757
758 // start focus trapping
759 document.addEventListener('focus', this.handleFocus, true);
760 } else {
761 this.el.removeAttribute('aria-hidden');
762
763 // remove css classes and unhide content from screen readers
764 this.el.classList.remove(SHOW_MENU);
765
766 /**
767 * Remove tabindex from the menu component
768 * so that is cannot be tabbed to.
769 */
770 this.el.removeAttribute('tabindex');
771 if (this.contentEl) {
772 this.contentEl.classList.remove(MENU_CONTENT_OPEN);
773
774 /**
775 * Remove aria-hidden so screen readers
776 * can announce the main content again
777 * now that the menu is not the main focus.
778 */
779 this.contentEl.removeAttribute('aria-hidden');

Callers 3

_setOpenMethod · 0.95
onEndMethod · 0.95
updateStateMethod · 0.95

Calls 5

isPlatformFunction · 0.90
unblockMethod · 0.80
stopMethod · 0.80
addEventListenerMethod · 0.65
removeEventListenerMethod · 0.65

Tested by

no test coverage detected