question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Modals do not show components in production only

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

In Ionic Vue, when creating modals through the modalController, the components will not show and will be rendered as comments. This will only happen, when building for production. In development mode the modals will render just fine.

Expected Behavior

Modals will render in productino as well.

Steps to Reproduce

Create an ionic project with ionic:

ionic start myApp blank --type vue

Create a button that triggers a new modal with the modalController and a minimal component like:

  const createSomeModal = await modalController.create({
    component: SomeModal,
  });
  createSomeModal.present();
  await createSomeModal.onDidDismiss();

Build for production

npm run build

And serve this anyhow, i used the php-webserver.

php -S 127.0.0.1:3000 -t dist

Now go on the website http://127.0.0.1:3000, open the modal and see no content. I made these reproduction steps in a repository here: https://github.com/schmop/ionic-modal-on-prod-broken

Code Reproduction URL

https://github.com/schmop/ionic-modal-on-prod-broken

Ionic Info

[WARN] Error loading @capacitor/ios package.json: Error: Cannot find module ‘@capacitor/ios/package’

   Require stack:
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\lib\project\index.js
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\lib\index.js
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\index.js
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\bin\ionic

[WARN] Error loading @capacitor/android package.json: Error: Cannot find module ‘@capacitor/android/package’

   Require stack:
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\lib\project\index.js
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\lib\index.js
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\index.js
   - C:\Users\schmop\AppData\Roaming\npm\node_modules\@ionic\cli\bin\ionic

Ionic:

Ionic CLI : 6.19.1 (C:\Users\schmop\AppData\Roaming\npm\node_modules@ionic\cli) Ionic Framework : @ionic/vue 6.1.8

Capacitor:

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

Utility:

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

System:

NodeJS : v16.14.0 (C:\Program Files\nodejs\node.exe) npm : 8.3.1 OS : Windows 10

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
liamdebeasicommented, Jun 3, 2022

Thanks for the issue. I can reproduce this behavior, but it does not appear to be an Ionic bug.

When running the app in production mode, ion-modal is still defined, but Vue renders the inner component as a comment (<!---->). Ionic Vue does not handle the rendering of SomeModal as we pass that off to Vue.


I looked at your application’s built output and it appears that the template for SomeModal is not being included. However, the component definition is there (I can see the console.log("Component mounted", this); log in the built output). This likely leads to the behavior described here where the component is mounted in the modal, but nothing shows up.

I also noticed that calling the modalController from inside the Home component instead seems to fix the issue.


Can you try moving the modalController to Home and let me know if that resolves the issue?

0reactions
ionitron-bot[bot]commented, Jul 6, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap modal not displaying - Stack Overflow
If you're running Bootstrap 4, it may be due to ".fade:not(.show) ...
Read more >
Bootstrap Modal Dialog showing under Modal Background
The easiest solution is to move the modal dialog outside of any container and just declare it under the <body> element, or -...
Read more >
Modal & Nonmodal Dialogs: When (& When Not) to Use Them
Modal dialogs interrupt users and demand an action. They are appropriate when user's attention needs to be directed toward important ...
Read more >
10 Most Common Bootstrap Mistakes That Developers Make
Bootstrap doesn't support overlapping modals. Only one modal at the time can be visible. Showing more than one modal at a time can...
Read more >
Modal&#38;#039;s are hiding behind NavBar &#38
p><strong>Expected behavior</strong> Modals covering the entire window</p> <p><strong>Actual behavior</strong> Modals are hiding behind NavBar & ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found