Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: backdrop not shown when IonDatetime is used in IonModal #29507

Open
3 tasks done
mattalco opened this issue May 15, 2024 · 2 comments
Open
3 tasks done

bug: backdrop not shown when IonDatetime is used in IonModal #29507

mattalco opened this issue May 15, 2024 · 2 comments
Assignees
Labels

Comments

@mattalco
Copy link

mattalco commented May 15, 2024

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

When IonDatetime is used within an IonModal, the backdrop that is supposed to accompany the date/time selector doesn't appear.

Expected Behavior

When IonDatetime is used within an IonModal, the backdrop as appears here in the docs appears correctly.

Steps to Reproduce

Create basic Ionic app
Create an IonModal
Inside that IonModal, place an IonDatetimeButton component
Within the element as the base IonModal, place the Basic Usage code provided here: https://ionicframework.com/docs/api/datetime-button

Code Reproduction URL

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

Ionic Info

Ionic:

Ionic CLI : 7.2.0 (/Users//.npm-packages/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 8.1.2

Capacitor:

Capacitor CLI : 6.0.0
@capacitor/android : not installed
@capacitor/core : 6.0.0
@capacitor/ios : not installed

Utility:

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

System:

NodeJS : v20.11.0 (/usr/local/bin/node)
npm : 10.2.4
OS : macOS Unknown

Additional Information

I feel like there needs to be some way for a modal associated with a datetime modal to have a higer z-index so the backdrop appears correctly. I tried supplying my own IonBackdrop but couldn't get that to work. I can manually edit the :host pseudo selector in the dev tools and increase the z-index to a value that works (11 vs. 2).
Screenshot 2024-05-15 at 16 24 28

@thetaPC
Copy link
Contributor

thetaPC commented May 17, 2024

Thank you for submitting the issue!

Could you provide more context of why you would like a nested modal?

I would recommend using a popover instead. This provides the backdrop plus there won't be a need a secondary modal.

<IonPopover keepContentsMounted={true}>
  <IonDatetime id="datetime"></IonDatetime>
</IonPopover>
<IonModal isOpen={true}>
  <IonHeader>
    <IonToolbar>
      <IonTitle>Bug Demo</IonTitle>
    </IonToolbar>
  </IonHeader>
  <div
    style={{
      height: '100%',
      display: 'flex',
      alignContent: 'center',
      justifyContent: 'center',
    }}
  >
    <IonDatetimeButton datetime="datetime"></IonDatetimeButton>
  </div>
</IonModal>

@thetaPC thetaPC added the needs: reply the issue needs a response from the user label May 17, 2024
@ionitron-bot ionitron-bot bot removed the triage label May 17, 2024
@mattalco
Copy link
Author

The popover does technically work but is an unsatisfactory user experience. I much prefer the larger tap space and centeredness of the modal style vs the popover.

For example, here is a modal dialog from my app.
IMG_1030
IMG_1029

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants