Skip to content

Commit 6e07a6f

Browse files
committed
refactor(modal): add requested changes
1 parent 3a79743 commit 6e07a6f

File tree

16 files changed

+63
-62
lines changed

16 files changed

+63
-62
lines changed

core/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ ion-modal,prop,backdropDismiss,boolean,true,false,false
10741074
ion-modal,prop,breakpoints,number[] | undefined,undefined,false,false
10751075
ion-modal,prop,canDismiss,((data?: any, role?: string | undefined) => Promise<boolean>) | boolean,true,false,false
10761076
ion-modal,prop,enterAnimation,((baseEl: any, opts?: any) => Animation) | undefined,undefined,false,false
1077+
ion-modal,prop,expandToScroll,boolean,true,false,false
10771078
ion-modal,prop,focusTrap,boolean,true,false,false
10781079
ion-modal,prop,handle,boolean | undefined,undefined,false,false
10791080
ion-modal,prop,handleBehavior,"cycle" | "none" | undefined,'none',false,false
@@ -1085,7 +1086,6 @@ ion-modal,prop,keyboardClose,boolean,true,false,false
10851086
ion-modal,prop,leaveAnimation,((baseEl: any, opts?: any) => Animation) | undefined,undefined,false,false
10861087
ion-modal,prop,mode,"ios" | "md",undefined,false,false
10871088
ion-modal,prop,presentingElement,HTMLElement | undefined,undefined,false,false
1088-
ion-modal,prop,scrollAtEdge,boolean,true,false,false
10891089
ion-modal,prop,showBackdrop,boolean,true,false,false
10901090
ion-modal,prop,trigger,string | undefined,undefined,false,false
10911091
ion-modal,method,dismiss,dismiss(data?: any, role?: string) => Promise<boolean>

core/src/components.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,10 @@ export namespace Components {
17311731
* Animation to use when the modal is presented.
17321732
*/
17331733
"enterAnimation"?: AnimationBuilder;
1734+
/**
1735+
* Determines whether or not the sheet modal will only scroll/drag the content when fully expanded. This will only take effect when the `breakpoints` and `initialBreakpoint` properties are set. If the value is `true`, the modal will only scroll when fully expanded. If the value is `false`, the modal will scroll at any breakpoint.
1736+
*/
1737+
"expandToScroll": boolean;
17341738
/**
17351739
* If `true`, focus will not be allowed to move outside of this overlay. If `false`, focus will be allowed to move outside of the overlay. In most scenarios this property should remain set to `true`. Setting this property to `false` can cause severe accessibility issues as users relying on assistive technologies may be able to move focus into a confusing state. We recommend only setting this to `false` when absolutely necessary. Developers may want to consider disabling focus trapping if this overlay presents a non-Ionic overlay from a 3rd party library. Developers would disable focus trapping on the Ionic overlay when presenting the 3rd party overlay and then re-enable focus trapping when dismissing the 3rd party overlay and moving focus back to the Ionic overlay.
17361740
*/
@@ -1793,10 +1797,6 @@ export namespace Components {
17931797
* The element that presented the modal. This is used for card presentation effects and for stacking multiple modals on top of each other. Only applies in iOS mode.
17941798
*/
17951799
"presentingElement"?: HTMLElement;
1796-
/**
1797-
* Determines whether or not the sheet modal will only scroll when fully expanded. If the value is `true`, the modal will only scroll when fully expanded. If the value is `false`, the modal will scroll at any breakpoint.
1798-
*/
1799-
"scrollAtEdge": boolean;
18001800
/**
18011801
* Move a sheet style modal to a specific breakpoint. The breakpoint value must be a value defined in your `breakpoints` array.
18021802
*/
@@ -6536,6 +6536,10 @@ declare namespace LocalJSX {
65366536
* Animation to use when the modal is presented.
65376537
*/
65386538
"enterAnimation"?: AnimationBuilder;
6539+
/**
6540+
* Determines whether or not the sheet modal will only scroll/drag the content when fully expanded. This will only take effect when the `breakpoints` and `initialBreakpoint` properties are set. If the value is `true`, the modal will only scroll when fully expanded. If the value is `false`, the modal will scroll at any breakpoint.
6541+
*/
6542+
"expandToScroll"?: boolean;
65396543
/**
65406544
* If `true`, focus will not be allowed to move outside of this overlay. If `false`, focus will be allowed to move outside of the overlay. In most scenarios this property should remain set to `true`. Setting this property to `false` can cause severe accessibility issues as users relying on assistive technologies may be able to move focus into a confusing state. We recommend only setting this to `false` when absolutely necessary. Developers may want to consider disabling focus trapping if this overlay presents a non-Ionic overlay from a 3rd party library. Developers would disable focus trapping on the Ionic overlay when presenting the 3rd party overlay and then re-enable focus trapping when dismissing the 3rd party overlay and moving focus back to the Ionic overlay.
65416545
*/
@@ -6622,10 +6626,6 @@ declare namespace LocalJSX {
66226626
* The element that presented the modal. This is used for card presentation effects and for stacking multiple modals on top of each other. Only applies in iOS mode.
66236627
*/
66246628
"presentingElement"?: HTMLElement;
6625-
/**
6626-
* Determines whether or not the sheet modal will only scroll when fully expanded. If the value is `true`, the modal will only scroll when fully expanded. If the value is `false`, the modal will scroll at any breakpoint.
6627-
*/
6628-
"scrollAtEdge"?: boolean;
66296629
/**
66306630
* If `true`, a backdrop will be displayed behind the modal. This property controls whether or not the backdrop darkens the screen when the modal is presented. It does not control whether or not the backdrop is active or present in the DOM.
66316631
*/

core/src/components/modal/animations/ios.enter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const createEnterAnimation = () => {
2424
* iOS Modal Enter Animation for the Card presentation style
2525
*/
2626
export const iosEnterAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptions): Animation => {
27-
const { presentingEl, currentBreakpoint, scrollAtEdge } = opts;
27+
const { presentingEl, currentBreakpoint, expandToScroll } = opts;
2828
const root = getElementRoot(baseEl);
2929
const { wrapperAnimation, backdropAnimation, contentAnimation } =
3030
currentBreakpoint !== undefined ? createSheetEnterAnimation(opts) : createEnterAnimation();
@@ -35,15 +35,15 @@ export const iosEnterAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptio
3535

3636
// The content animation is only added if scrolling is enabled for
3737
// all the breakpoints.
38-
!scrollAtEdge && contentAnimation?.addElement(baseEl.querySelector('.ion-page')!);
38+
!expandToScroll && contentAnimation?.addElement(baseEl.querySelector('.ion-page')!);
3939

4040
const baseAnimation = createAnimation('entering-base')
4141
.addElement(baseEl)
4242
.easing('cubic-bezier(0.32,0.72,0,1)')
4343
.duration(500)
4444
.addAnimation([wrapperAnimation])
4545
.beforeAddWrite(() => {
46-
if (scrollAtEdge) {
46+
if (expandToScroll) {
4747
// Scroll can only be done when the modal is fully expanded.
4848
return;
4949
}

core/src/components/modal/animations/ios.leave.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const createLeaveAnimation = () => {
1919
* iOS Modal Leave Animation
2020
*/
2121
export const iosLeaveAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptions, duration = 500): Animation => {
22-
const { presentingEl, currentBreakpoint, scrollAtEdge } = opts;
22+
const { presentingEl, currentBreakpoint, expandToScroll } = opts;
2323
const root = getElementRoot(baseEl);
2424
const { wrapperAnimation, backdropAnimation } =
2525
currentBreakpoint !== undefined ? createSheetLeaveAnimation(opts) : createLeaveAnimation();
@@ -34,13 +34,13 @@ export const iosLeaveAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptio
3434
.duration(duration)
3535
.addAnimation(wrapperAnimation)
3636
.beforeAddWrite(() => {
37-
if (scrollAtEdge) {
37+
if (expandToScroll) {
3838
// Scroll can only be done when the modal is fully expanded.
3939
return;
4040
}
4141

4242
/**
43-
* If scrollAtEdge is disabled, we need to swap
43+
* If expandToScroll is disabled, we need to swap
4444
* the visibility to the original, so the footer
4545
* dismisses with the modal and doesn't stay
4646
* until the modal is removed from the DOM.

core/src/components/modal/animations/md.enter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const createEnterAnimation = () => {
2626
* Md Modal Enter Animation
2727
*/
2828
export const mdEnterAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptions): Animation => {
29-
const { currentBreakpoint, scrollAtEdge } = opts;
29+
const { currentBreakpoint, expandToScroll } = opts;
3030
const root = getElementRoot(baseEl);
3131
const { wrapperAnimation, backdropAnimation, contentAnimation } =
3232
currentBreakpoint !== undefined ? createSheetEnterAnimation(opts) : createEnterAnimation();
@@ -37,15 +37,15 @@ export const mdEnterAnimation = (baseEl: HTMLElement, opts: ModalAnimationOption
3737

3838
// The content animation is only added if scrolling is enabled for
3939
// all the breakpoints.
40-
scrollAtEdge && contentAnimation?.addElement(baseEl.querySelector('.ion-page')!);
40+
expandToScroll && contentAnimation?.addElement(baseEl.querySelector('.ion-page')!);
4141

4242
const baseAnimation = createAnimation()
4343
.addElement(baseEl)
4444
.easing('cubic-bezier(0.36,0.66,0.04,1)')
4545
.duration(280)
4646
.addAnimation([backdropAnimation, wrapperAnimation])
4747
.beforeAddWrite(() => {
48-
if (scrollAtEdge) {
48+
if (expandToScroll) {
4949
// Scroll can only be done when the modal is fully expanded.
5050
return;
5151
}

core/src/components/modal/animations/md.leave.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const createLeaveAnimation = () => {
2121
* Md Modal Leave Animation
2222
*/
2323
export const mdLeaveAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptions): Animation => {
24-
const { currentBreakpoint, scrollAtEdge } = opts;
24+
const { currentBreakpoint, expandToScroll } = opts;
2525
const root = getElementRoot(baseEl);
2626
const { wrapperAnimation, backdropAnimation } =
2727
currentBreakpoint !== undefined ? createSheetLeaveAnimation(opts) : createLeaveAnimation();
@@ -34,13 +34,13 @@ export const mdLeaveAnimation = (baseEl: HTMLElement, opts: ModalAnimationOption
3434
.duration(200)
3535
.addAnimation([backdropAnimation, wrapperAnimation])
3636
.beforeAddWrite(() => {
37-
if (scrollAtEdge) {
37+
if (expandToScroll) {
3838
// Scroll can only be done when the modal is fully expanded.
3939
return;
4040
}
4141

4242
/**
43-
* If scrollAtEdge is disabled, we need to swap
43+
* If expandToScroll is disabled, we need to swap
4444
* the visibility to the original, so the footer
4545
* dismisses with the modal and doesn't stay
4646
* until the modal is removed from the DOM.

core/src/components/modal/animations/sheet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ModalAnimationOptions } from '../modal-interface';
44
import { getBackdropValueForSheet } from '../utils';
55

66
export const createSheetEnterAnimation = (opts: ModalAnimationOptions) => {
7-
const { currentBreakpoint, backdropBreakpoint, scrollAtEdge } = opts;
7+
const { currentBreakpoint, backdropBreakpoint, expandToScroll } = opts;
88

99
/**
1010
* If the backdropBreakpoint is undefined, then the backdrop
@@ -32,7 +32,7 @@ export const createSheetEnterAnimation = (opts: ModalAnimationOptions) => {
3232
/**
3333
* This allows the content to be scrollable at any breakpoint.
3434
*/
35-
const contentAnimation = !scrollAtEdge
35+
const contentAnimation = !expandToScroll
3636
? createAnimation('contentAnimation').keyframes([
3737
{ offset: 0, opacity: 1, maxHeight: `${(1 - currentBreakpoint!) * 100}%` },
3838
{ offset: 1, opacity: 1, maxHeight: `${currentBreakpoint! * 100}%` },

core/src/components/modal/gestures/sheet.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const createSheetGesture = (
4949
backdropBreakpoint: number,
5050
animation: Animation,
5151
breakpoints: number[] = [],
52-
scrollAtEdge: boolean,
52+
expandToScroll: boolean,
5353
getCurrentBreakpoint: () => number,
5454
onDismiss: () => void,
5555
onBreakpointChange: (breakpoint: number) => void
@@ -117,7 +117,7 @@ export const createSheetGesture = (
117117
};
118118

119119
/**
120-
* Used when `scrollAtEdge` is disabled.
120+
* Used when `expandToScroll` is disabled.
121121
* Changes the footer that is currently visible
122122
* @param footer - The footer to show
123123
*/
@@ -171,7 +171,7 @@ export const createSheetGesture = (
171171
}
172172
}
173173

174-
if (contentEl && currentBreakpoint !== maxBreakpoint && scrollAtEdge) {
174+
if (contentEl && currentBreakpoint !== maxBreakpoint && expandToScroll) {
175175
contentEl.scrollY = false;
176176
}
177177

@@ -188,10 +188,10 @@ export const createSheetGesture = (
188188
currentBreakpoint = getCurrentBreakpoint();
189189

190190
/**
191-
* If we have scrollAtEdge disabled, we should not allow the swipe gesture to start
191+
* If we have expandToScroll disabled, we should not allow the swipe gesture to start
192192
* if the content is being swiped.
193193
*/
194-
if (!scrollAtEdge && contentEl) {
194+
if (!expandToScroll && contentEl) {
195195
return false;
196196
}
197197

@@ -229,12 +229,12 @@ export const createSheetGesture = (
229229
canDismissBlocksGesture = baseEl.canDismiss !== undefined && baseEl.canDismiss !== true && minBreakpoint === 0;
230230

231231
/**
232-
* If scrollAtEdge is disabled, we need to swap
232+
* If expandToScroll is disabled, we need to swap
233233
* the visibility to the original, so if the modal
234234
* is dismissed, the footer dismisses with the modal
235235
* and doesn't stay on the screen after the modal is gone.
236236
*/
237-
if (!scrollAtEdge) {
237+
if (!expandToScroll) {
238238
swapFooterVisibility('original');
239239
}
240240

@@ -376,7 +376,7 @@ export const createSheetGesture = (
376376

377377
if (contentAnimation) {
378378
/**
379-
* The modal content should scroll at any breakpoint when scrollAtEdge
379+
* The modal content should scroll at any breakpoint when expandToScroll
380380
* is disabled. In order to do this, the content needs to be completely
381381
* viewable so scrolling can access everything. Othewise, the default
382382
* behavior would show the content off the screen and only allow
@@ -398,11 +398,11 @@ export const createSheetGesture = (
398398
gesture.enable(false);
399399

400400
/**
401-
* If scrollAtEdge is disabled, we need to swap
401+
* If expandToScroll is disabled, we need to swap
402402
* the visibility to the cloned one so the footer
403403
* doesn't flicker when the sheet's height is animated.
404404
*/
405-
if (!scrollAtEdge && shouldRemainOpen) {
405+
if (!expandToScroll && shouldRemainOpen) {
406406
swapFooterVisibility('cloned');
407407
}
408408

@@ -420,7 +420,7 @@ export const createSheetGesture = (
420420
* for when scrolling is re-enabled. Native iOS allows for scrolling on the
421421
* sheet modal as soon as the gesture is released, so we align with that.
422422
*/
423-
if (contentEl && (snapToBreakpoint === breakpoints[breakpoints.length - 1] || !scrollAtEdge)) {
423+
if (contentEl && (snapToBreakpoint === breakpoints[breakpoints.length - 1] || !expandToScroll)) {
424424
contentEl.scrollY = true;
425425
}
426426

core/src/components/modal/modal-interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ModalAnimationOptions {
3131
presentingEl?: HTMLElement;
3232
currentBreakpoint?: number;
3333
backdropBreakpoint?: number;
34-
scrollAtEdge: boolean;
34+
expandToScroll: boolean;
3535
}
3636

3737
export interface ModalBreakpointChangeEventDetail {

core/src/components/modal/modal.ios.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@
9696
* `core.scss` file. However, there's a workaround that requires
9797
* a cloned footer to be added to the modal. This is only necessary
9898
* because the core styles are not being applied to the cloned footer.
99-
* It's important to update the padding value when the core styles are
100-
* updated.
10199
*/
102-
:host(.modal-sheet.modal-scroll-all) ion-footer ion-toolbar:first-of-type {
103-
padding-top: 6px;
100+
:host(.modal-sheet.modal-no-expand-scroll) ion-footer ion-toolbar:first-of-type {
101+
padding-top: $modal-sheet-padding-top;
104102
}

0 commit comments

Comments
 (0)