mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
fix(modal): swipe to dismiss resets status bar style (#28110)
Issue number: resolves #28105 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> When swiping to dismiss the card modal, the status bar style is reset too late. Since we are using 1 animation for the card modal, the dismiss animation is played _then_ the `dismiss` method is called (which resets the status bar style). This means the status bar style is wrong for the duration of the dismiss animation. This does not impact dragging to close the modal such that the status bar changes mid-gesture or calling the `dismiss` method directly -- only quickly swiping to dismiss. Also one of the changes in core/src/components/modal/modal.tsx accidentally changed the modal behavior so that the status bar is changed _after_ the present transition finishes. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - When the card modal is swiped to dismiss the `onDismiss` callback will also reset the status bar style. - When the card modal is presented the status bar is set correctly as the animation begins | `main` | branch | | - | - | | <video src="https://github.com/ionic-team/ionic-framework/assets/2721089/8a18419d-a7ec-4629-8632-62e2ed401912"></video> | <video src="https://github.com/ionic-team/ionic-framework/assets/2721089/62ffcf00-8dbd-4e0c-83a3-5af5d463bccc"></video> | ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.3.3-dev.11693592322.138d91e6`
This commit is contained in:
@ -473,6 +473,19 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
|
|
||||||
writeTask(() => this.el.classList.add('show-modal'));
|
writeTask(() => this.el.classList.add('show-modal'));
|
||||||
|
|
||||||
|
const hasCardModal = presentingElement !== undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We need to change the status bar at the
|
||||||
|
* start of the animation so that it completes
|
||||||
|
* by the time the card animation is done.
|
||||||
|
*/
|
||||||
|
if (hasCardModal && getIonMode(this) === 'ios') {
|
||||||
|
// Cache the original status bar color before the modal is presented
|
||||||
|
this.statusBarStyle = await StatusBar.getStyle();
|
||||||
|
setCardStatusBarDark();
|
||||||
|
}
|
||||||
|
|
||||||
await present<ModalPresentOptions>(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation, {
|
await present<ModalPresentOptions>(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation, {
|
||||||
presentingEl: presentingElement,
|
presentingEl: presentingElement,
|
||||||
currentBreakpoint: this.initialBreakpoint,
|
currentBreakpoint: this.initialBreakpoint,
|
||||||
@ -511,19 +524,6 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
window.addEventListener(KEYBOARD_DID_OPEN, this.keyboardOpenCallback);
|
window.addEventListener(KEYBOARD_DID_OPEN, this.keyboardOpenCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasCardModal = presentingElement !== undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We need to change the status bar at the
|
|
||||||
* start of the animation so that it completes
|
|
||||||
* by the time the card animation is done.
|
|
||||||
*/
|
|
||||||
if (hasCardModal && getIonMode(this) === 'ios') {
|
|
||||||
// Cache the original status bar color before the modal is presented
|
|
||||||
this.statusBarStyle = await StatusBar.getStyle();
|
|
||||||
setCardStatusBarDark();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isSheetModal) {
|
if (this.isSheetModal) {
|
||||||
this.initSheetGesture();
|
this.initSheetGesture();
|
||||||
} else if (hasCardModal) {
|
} else if (hasCardModal) {
|
||||||
@ -566,6 +566,16 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
* removed from the DOM.
|
* removed from the DOM.
|
||||||
*/
|
*/
|
||||||
this.gestureAnimationDismissing = true;
|
this.gestureAnimationDismissing = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the status bar style as the dismiss animation
|
||||||
|
* starts otherwise the status bar will be the wrong
|
||||||
|
* color for the duration of the dismiss animation.
|
||||||
|
* The dismiss method does this as well, but
|
||||||
|
* in this case it's only called once the animation
|
||||||
|
* has finished.
|
||||||
|
*/
|
||||||
|
setCardStatusBarDefault(this.statusBarStyle);
|
||||||
this.animation!.onFinish(async () => {
|
this.animation!.onFinish(async () => {
|
||||||
await this.dismiss(undefined, GESTURE);
|
await this.dismiss(undefined, GESTURE);
|
||||||
this.gestureAnimationDismissing = false;
|
this.gestureAnimationDismissing = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user