Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Multiple modals won't open reliably #218

Open
nburnesy opened this issue Nov 12, 2017 · 3 comments
Open

Multiple modals won't open reliably #218

nburnesy opened this issue Nov 12, 2017 · 3 comments

Comments

@nburnesy
Copy link

nburnesy commented Nov 12, 2017

If I have 2 modals, one of them won't open reliably. In this example if I repeatedly click Open Second it will stop opening after a few tries. Opening the first modal then opening the second will work again (at least once).

Edit: The second modal will always open when I press esc to dismiss, if I click to dismiss it will stop opening.

I'm currently avoiding this by calling dismissAll() on the BsModalService before opening a modal.

import { Component, OnInit, ViewChild } from '@angular/core';
import { BsModalComponent } from 'ng2-bs3-modal';

@Component({
  selector: 'ng-test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.css']
})
export class TestComponent {

  @ViewChild('firstModal')
  firstModal: BsModalComponent;

  @ViewChild('secondModal')
  secondModal: BsModalComponent;

  constructor() { }

  openFirst() {
    this.firstModal.open();
  }

  openSecond() {
    this.secondModal.open();
  }
}
<button (click)="openFirst()">Open First</button>
<button (click)="openSecond()">Open Second</button>

<bs-modal #firstModal>
    <bs-modal-body>
        First Contents
    </bs-modal-body>
</bs-modal>

<bs-modal #secondModal>
    <bs-modal-body>
        Second Contents
    </bs-modal-body>
</bs-modal>
@pjmolina
Copy link

pjmolina commented Mar 8, 2018

Same problem here. Any fix or workaround available?

@nburnesy
Copy link
Author

nburnesy commented Mar 8, 2018

Yes, from my original post:

I'm currently avoiding this by calling dismissAll() on the BsModalService before opening a modal.

@pjmolina
Copy link

pjmolina commented Mar 8, 2018

Sorry. Already tried it, but your fix is not working for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants