-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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: conditionally rendered modal via route doesn't close when navigating away #25775
Comments
Thanks for the issue. Are you able to provide a repo that contains only the minimum amount of code required to reproduce this issue? I am getting import errors when I try to run your app, possibly due to outdated dependencies. |
Hmm that's interesting , maybe because I was using yarn instead of npm. |
@liamdebeasi - here's an even smaller repo: https://github.com/corysmc/test-route-modal |
Thanks. While coupling modals with routing is an anti-pattern and not something we encourage, conditionally rendering the modal should remove the underlying Web Component. Let me take a closer look and see why this is happening. |
Thanks @liamdebeasi - I really appreciate it! I totally agree about the anti-pattern. I'll see if we can make the change internally to use modals properly. For reference here's another related issue |
Hey @corysmc can you test with this dev-build and let me know if you run into any odd quirks? npm i @ionic/[email protected] @ionic/[email protected] I tested with the |
|
Any status update on this fix? |
@puopg this is still an active bug in discovery/development. The issue of dismissing the overlay on route navigation has been resolved in the dev-build, but is also dependent on another bug: #25590 that requires additional effort. We have multiple strategies of presenting and controlling the rendering of overlays ( I will share an update on both issues once I validate a strategy that works and is well tested. I will also likely share a new dev-build when that occurs. Thanks! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
Current Behavior
After updating to ionic 6, Conditionally rendered ion-modals are not dismissing after changing routes. There's a fix in route for an error that happened when the modal was removed from the dom #25590 - but now the modal won't dismiss when navigating away, and the animations aren't happening - and the modal won't dismiss after changing routes.
A route based conditionally rendered IonModal worked in ionic v5 - and I've been told this is a common pattern in a react app, so I would expect this to work out of the box.
Video:
Here's a video of the simple demo I put together based off of a fork from the ionic-react-conference app
https://user-images.githubusercontent.com/6452188/185195963-06ad49bf-0533-41ba-9f6e-0cb01326eff9.mov
Expected Behavior
When conditionally rendering an IonModal in React I would expect to be able to show/hide an ion modal based on a matched route. Ideally it would also animate in/out when mounting and unmounting (see video for hack workaround to get this working)
Steps to Reproduce
isOpen={true}
Step 1
yarn add @ionic/[email protected]
andyarn add @ionic/[email protected]
ornpm i @ionic/[email protected]
andnpm i @ionic/[email protected]
Step 2
The SupportModal component above looks something like this:
<IonModal isOpen>...
Step 3
Step 4
Add this to the
SupportModal
<IonButton href="/support">Go Back</IonButton>
Full code here: https://github.com/corysmc/ionic-react-conference-app
Code Reproduction URL
https://github.com/corysmc/ionic-react-conference-app
Ionic Info
Ionic:
Ionic CLI : 6.19.0
Ionic Framework : @ionic/react 6.2.3-dev.11660337759.18ea0f7e
Capacitor:
Capacitor CLI : 1.3.0
@capacitor/android : not installed
@capacitor/core : 1.3.0
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : not installed globally
System:
NodeJS : v14.18.2
npm : 6.14.15
OS : macOS Monterey
Additional Information
Related issues
#25590
#24887
The text was updated successfully, but these errors were encountered: