From bdb7cd6a21e41bfcfd58393cc63cbb647973cbbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Louren=C3=A7o?= Date: Tue, 22 Oct 2024 16:03:11 +0100 Subject: [PATCH] fix(modal): fix enter animation when the initial breakpoint value is less than the backdrop breakpoint (#29955) Issue number: internal --------- ## What is the current behavior? This PR aims to fix an issue introduced in https://github.com/ionic-team/ionic-framework/pull/29932 where the enter animation for ionic theme was in a broken state when the modal's initial breakpoint value was lesser than the specified backdrop breakpoint. ## What is the new behavior? - The erroneous behaviour happened because the shouldShowBackdrop constant had a false value which was being taken into consideration when computing the backdrop opacity for the ionic theme. This PR fixes this by always transitioning the backdrop opacity from 0 to 0.7 once the modal appears, independently of the initial, current or activation breakpoint. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information --- core/src/components/modal/animations/sheet.ts | 9 ++++++--- core/src/components/modal/modal.tsx | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/components/modal/animations/sheet.ts b/core/src/components/modal/animations/sheet.ts index 8224effb9f..a786f5dbf9 100644 --- a/core/src/components/modal/animations/sheet.ts +++ b/core/src/components/modal/animations/sheet.ts @@ -12,9 +12,12 @@ export const createSheetEnterAnimation = (opts: ModalAnimationOptions) => { * current breakpoint, then the backdrop should be fading in. */ const shouldShowBackdrop = backdropBreakpoint === undefined || backdropBreakpoint < currentBreakpoint!; - const initialBackdrop = shouldShowBackdrop - ? `calc(var(--backdrop-opacity) * ${staticBackdropOpacity ? 1 : currentBreakpoint!})` - : '0'; + let initialBackdrop = '0'; + if (staticBackdropOpacity) { + initialBackdrop = 'calc(var(--backdrop-opacity)'; + } else if (shouldShowBackdrop) { + initialBackdrop = `calc(var(--backdrop-opacity) * ${currentBreakpoint!})`; + } const backdropAnimation = createAnimation('backdropAnimation').fromTo('opacity', 0, initialBackdrop); diff --git a/core/src/components/modal/modal.tsx b/core/src/components/modal/modal.tsx index f9b161da6d..5dc1f2e069 100644 --- a/core/src/components/modal/modal.tsx +++ b/core/src/components/modal/modal.tsx @@ -1049,6 +1049,8 @@ interface ModalOverlayOptions { /** * The point after which the backdrop will begin * to fade in when using a sheet modal. + * This option is ignored for the ionic theme + * due to the option below. */ backdropBreakpoint: number; /**