Skip to content

bug: status bar styling not switching on close gesture for card modal #28105

@mortenbo

Description

@mortenbo

Hi! First off, loving Ionic, but I'm stumbling into some weird issues for a barebones React app. For example, the modal stutters as it finishes its animation + the statusbar style is not fluent when using swipe to dismiss. I'm also seeing weirdnesses when swiping back from a page when using a tabbar (sometimes, the offset changes so the page jumps 20px and sometimes the animation to close is very abrupt but I'll make a separate issue on that.).

I'm creating this issue/question before proceeding with building an Ionic app/prototype because if this behavior is expected then I think it may not be fluent enough for my needs. This is not a critique by any means.

Ionic version:
7.3.2

Dependencies:

  "dependencies": {
    "@capacitor/android": "5.3.0",
    "@capacitor/app": "5.0.6",
    "@capacitor/browser": "^5.0.6",
    "@capacitor/core": "5.3.0",
    "@capacitor/geolocation": "^5.0.6",
    "@capacitor/haptics": "^5.0.6",
    "@capacitor/ios": "5.3.0",
    "@capacitor/keyboard": "5.0.6",
    "@capacitor/status-bar": "5.0.6",
    "@ionic/core": "^7.3.2",
    "@ionic/react": "^7.3.2",
    "@ionic/react-router": "^7.3.2",
    "@types/react-router": "^5.1.20",
    "@types/react-router-dom": "^5.3.3",
    "ionicons": "^7.0.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-localization": "^1.0.19",
    "react-query": "^3.39.3",
    "react-router": "^5.3.4",
    "react-router-dom": "^5.3.4"
  },

I'm submitting a ...
[x] bug report (maybe)
[ ] feature request

Current behavior:
Modal animation stutters near the end + statusbar style doesn't change properly when swiping to close a modal.

It happens both in the simulator and on device. Here's a video of the simulator:

modal.mov

Expected behavior:
Based on what I've read about Ionic, animations should be super smooth + statusbar style should animate as well.

Steps to reproduce:
pages/Favorites.tsx:

import React, { useState, useRef, useEffect } from "react";
import {
  IonContent,
  IonHeader,
  IonPage,
  IonTitle,
  IonButton,
  IonButtons,
  IonToolbar,
  IonModal,
} from "@ionic/react";

const Favorites: React.FC = () => {
  const modal = useRef<HTMLIonModalElement>(null);
  const page = useRef(undefined);
  const [presentingElement, setPresentingElement] = useState<
    HTMLElement | undefined
  >(undefined);

  useEffect(() => {
    setPresentingElement(page.current);
  }, []);

  function dismiss() {
    modal.current?.dismiss();
  }

  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"
          presentingElement={presentingElement}
        >
          <IonHeader>
            <IonToolbar>
              <IonTitle>Modal</IonTitle>
              <IonButtons slot="end">
                <IonButton onClick={() => dismiss()}>Close</IonButton>
              </IonButtons>
            </IonToolbar>
          </IonHeader>
          <IonContent className="ion-padding"></IonContent>
        </IonModal>
      </IonContent>
    </IonPage>
  );
};

export default Favorites;

App.tsx:

import { IonApp, setupIonicReact } from "@ionic/react";
import Favorites from "./pages/Favorites";

/* Core CSS required for Ionic components to work properly */
import "@ionic/react/css/core.css";

/* Basic CSS for apps built with Ionic */
import "@ionic/react/css/normalize.css";
import "@ionic/react/css/structure.css";
import "@ionic/react/css/typography.css";

/* Optional CSS utils that can be commented out */
import "@ionic/react/css/padding.css";
import "@ionic/react/css/float-elements.css";
import "@ionic/react/css/text-alignment.css";
import "@ionic/react/css/text-transformation.css";
import "@ionic/react/css/flex-utils.css";
import "@ionic/react/css/display.css";

/* Theme variables */
import "./theme/variables.css";

setupIonicReact();

const App: React.FC = () => {
  return (
    <IonApp>
      <Favorites />
    </IonApp>
  );
};

export default App;

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