From c10df52f39c527dd7e03176c56a2e6cb0ebe455f Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Mon, 13 Jun 2022 13:37:11 -0400 Subject: [PATCH] fix(modal): backdrop animation when backdropBreakpoint is 1 (#25430) Resolves #25402 --- core/src/components/modal/utils.spec.ts | 11 +++++++++++ core/src/components/modal/utils.ts | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 core/src/components/modal/utils.spec.ts diff --git a/core/src/components/modal/utils.spec.ts b/core/src/components/modal/utils.spec.ts new file mode 100644 index 0000000000..b1a8492646 --- /dev/null +++ b/core/src/components/modal/utils.spec.ts @@ -0,0 +1,11 @@ +import { getBackdropValueForSheet } from './utils'; + +describe('getBackdropValueForSheet()', () => { + it('should return a valid integer when backdropBreakpoint is 1', () => { + /** + * Issue: https://github.com/ionic-team/ionic-framework/issues/25402 + */ + const backdropBreakpoint = 1; + expect(getBackdropValueForSheet(1, backdropBreakpoint)).toBe(0); + }); +}); diff --git a/core/src/components/modal/utils.ts b/core/src/components/modal/utils.ts index f8c13084af..e48e3113c6 100644 --- a/core/src/components/modal/utils.ts +++ b/core/src/components/modal/utils.ts @@ -23,7 +23,15 @@ export const getBackdropValueForSheet = (x: number, backdropBreakpoint: number) * * This is simplified from: * m = (1 - 0) / (maxBreakpoint - backdropBreakpoint) + * + * If the backdropBreakpoint is 1, we return 0 as the + * backdrop is completely hidden. + * */ + if (backdropBreakpoint === 1) { + return 0; + } + const slope = 1 / (1 - backdropBreakpoint); /**