Skip to content

bug: IonModal animation of swipe to close gesture is broken if canDismiss specified #30129

@da1z

Description

@da1z

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

Screen.Recording.2025-01-10.at.7.20.11.PM.mov

Expected Behavior

Animation works as expected, for example when canDismiss is not specified

Screen.Recording.2025-01-10.at.7.21.08.PM.mov

Steps to Reproduce

create modal that has canDismiss specified as function that returns true

  async function canDismiss(data?: any, role?: string) {
    return true;
  }

  return (
    <IonPage ref={page}>
      <IonHeader>
        <IonToolbar>
          <IonTitle>App</IonTitle>
        </IonToolbar>
      </IonHeader>
      <IonContent className="ion-padding">
        <IonButton id="open-modal" expand="block">
          Open
        </IonButton>
        <IonModal
          ref={modal}
          trigger="open-modal"
          canDismiss={canDismiss}
          presentingElement={presentingElement!}
        >
          <IonHeader>
            <IonToolbar>
              <IonTitle>Modal</IonTitle>
              <IonButtons slot="end">
                <IonButton onClick={() => dismiss()}>Close</IonButton>
              </IonButtons>
            </IonToolbar>
          </IonHeader>
          <IonContent className="ion-padding">
            <p>
              To close this modal, please use the "Close" button provided. Note
              that swiping the modal will not dismiss it.
            </p>
          </IonContent>
        </IonModal>
      </IonContent>
    </IonPage>
  );

Code Reproduction URL

https://stackblitz.com/edit/k9wbj9qc?file=src%2Fmain.tsx

Ionic Info

running in stackblitz

Ionic:

Ionic CLI : 5.4.16

Utility:

cordova-res : not installed
native-run : not installed

System:

NodeJS : v18.20.3
npm : 10.2.3
OS : Linux 5.0

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions