ion-slides not working in modal when ion-button is present in modal
See original GitHub issueBug Report
Ionic version:
[x] 4.0.1
Current behavior: On second opening of modal view with ion-slides and ion-button inside of modal template ion-slides becomes unresponsive, without ion-button everything is working correctly
Expected behavior: ion-slides should work correctly everytime modal is opened and it should not depend on other components in templates like ion-button
Steps to reproduce: Use ionic source code, core->src->components->modal->test->basic and add to test ion-slides, first time when modal is opened everything is ok, second time that modal is opened it is unresponsive, if you change ion-button in test with anchor tag everything is going to be ok
Related code:
Not working
async function createModal() {
// initialize controller
const modalController = document.querySelector('ion-modal-controller');
await modalController.componentOnReady();
// create component to open
const element = document.createElement('div');
element.innerHTML = `
<ion-header>
<ion-toolbar>
<ion-title>Super Modal</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<h1>Content of doom</h1>
<div>Here's some more content</div>
<ion-slides mode="md">
<ion-slide>
<div>1</div>
</ion-slide>
<ion-slide>
<div>2</div>
</ion-slide>
<ion-slide>
<div>3</div>
</ion-slide>
</ion-slides>
<ion-button class="dismiss">Dismiss Modal</ion-button>
</ion-content>
`;
// listen for close event
const button = element.querySelector('ion-button');
button.addEventListener('click', () => {
modalController.dismiss();
});
// present the modal
const modalElement = await modalController.create({
component: element
});
return modalElement;
}
Working
async function createModal() {
// initialize controller
const modalController = document.querySelector('ion-modal-controller');
await modalController.componentOnReady();
// create component to open
const element = document.createElement('div');
element.innerHTML = `
<ion-header>
<ion-toolbar>
<ion-title>Super Modal</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<h1>Content of doom</h1>
<div>Here's some more content</div>
<ion-slides mode="md">
<ion-slide>
<div>1</div>
</ion-slide>
<ion-slide>
<div>2</div>
</ion-slide>
<ion-slide>
<div>3</div>
</ion-slide>
</ion-slides>
<a class="dismiss">Dismiss Modal</a>
</ion-content>
`;
// listen for close event
const button = element.querySelector('a');
button.addEventListener('click', () => {
modalController.dismiss();
});
// present the modal
const modalElement = await modalController.create({
component: element
});
return modalElement;
}
Other information:
Ionic info:
insert the output from ionic info here
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:16 (2 by maintainers)
Top Results From Across the Web
IonSlides ref not working when inside IonModal - Ionic Vue
I want to use the “slideTo” method with IonSlides in Ionic Vue. I tried adding a ref attribute like this: <ion-modal ...
Read more >ionic 4/5 issue with ion-slide and modal - Stack Overflow
I am trying to show an image preview using ion-slide inside the ion-modal. But zoom functionality is not working. I have added slideOptions....
Read more >How to Navigate in Ionic Modals with ion-nav - Ionic Blog
Let's build an app with navigation inside of a modal and make everything work, including the Android back button as well! Getting Started...
Read more >Ionic4 模态框组件ion-modal
A Modal is a dialog that appears on top of the app's content, and must be dismissed by the app before interaction can...
Read more >Building the Netflix UI with Ionic | Devdactic
We will work with directives to fade the header out, create a semi transparent modal with blurred background and also a bottom drawer...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my case that was a fix:
same here, showing IonSlides in a modal page result in a serious DEAD LOCK, chrome stops responding. no matter <ion-button> or <button>, the issue persistent. temperory solution is adding a settimeout to delay show IonSlides
@ionic/angular 4.0.2