Modals close when clicking random button on page

Hi !

So I created a modal that returns data to my page by following the norms.
But in this modal, I have another button that has a function link to it. I don’t know why but when I click on it, it dismisses my modal. Even if I remove the (click) part of the button, it still dismiss it. The button triggers his function like it should, but it looks like the viewCtrl dismiss it for whatever reason.

Thank you,

I’m doing this with Ionic Lab FYI.

I believe there’s a modal option for backdrop dismiss. Something like that. I think it’s in the ionic docs? If not, google it a while and you should find the answer. Something along these lines

let modalOptions = {
 backdropDismiss: false,
}
let myModal = this.modalCtrl.create(ModalPageToPresent, {}, modalOptions);

The {} is to act as a place holder for modalData, which goes in that position if I remember correctly.

this could also only apply to popovers, and I’m way off base. But I think I’m on the right path here

Tried that. Did not work. But I did fixed it by removing my button from my form. It seems the button to confirm my form was triggered by the other one because it was inside of it. Weird.

Ah. Makes sense. Forms are a cohesive group and don’t always mix well with others.

I had same issue and found that I had to in html
add type=“button”

          <button type="button" ion-button (click)="editMedicationQty(item,i,$event)">
 

and add $event

  editMedicationQty(editObj: Medications,idx,ev) {
    ev.stopPropagation();

not sure if i needed the $event setup, it worked so i left it :wink: