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); /**