From 38626d96809d1c6be523ea62a4fac1dec73ee891 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 20 Jul 2023 15:13:02 -0400 Subject: [PATCH] fix(modal): body background is reset with inline card modals (#27835) Issue number: resolves #27830 --------- ## What is the current behavior? Card modals set the body background to `black` to match iOS. This color should be removed once the final card modal has been closed. When modals were updated to work inline, the code that removed the background color was never updated to account for this. As a result, opening multiple inline card modals never removes the background color because there are always >1 modals in the DOM. ## What is the new behavior? - The card modal now queries for _visible_ modals in the DOM to determine if it should remove the background color. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information Dev-build: `7.2.1-dev.11689879279.14e28634` --- core/src/components/modal/animations/ios.leave.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/components/modal/animations/ios.leave.ts b/core/src/components/modal/animations/ios.leave.ts index 7fc235dea7..914652878f 100644 --- a/core/src/components/modal/animations/ios.leave.ts +++ b/core/src/components/modal/animations/ios.leave.ts @@ -51,9 +51,9 @@ export const iosLeaveAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptio presentingEl.style.setProperty('overflow', ''); - const numModals = Array.from(bodyEl.querySelectorAll('ion-modal')).filter( - (m) => m.presentingElement !== undefined - ).length; + const numModals = ( + Array.from(bodyEl.querySelectorAll('ion-modal:not(.overlay-hidden)')) as HTMLIonModalElement[] + ).filter((m) => m.presentingElement !== undefined).length; if (numModals <= 1) { bodyEl.style.setProperty('background-color', ''); }