Skip to content
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

Bugs in showing Modal #1144

Closed
hkb1990 opened this issue Oct 20, 2016 · 1 comment
Closed

Bugs in showing Modal #1144

hkb1990 opened this issue Oct 20, 2016 · 1 comment

Comments

@hkb1990
Copy link
Contributor

hkb1990 commented Oct 20, 2016

HTML part:

<button type="button" class="btn btn-primary" (click)="Test()">Start Test</button>
<div bsModal #smModal="bs-modal" [config]="{backdrop: false}"
 class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" aria-label="Close" (click)="Stop()">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">Small modal</h4>
      </div>
      <div class="modal-body">
        Count:{{cnt}}
      </div>
    </div>
  </div>
</div>

JS part:

@ViewChild('smModal') public smModal;
public cnt: number = 0;
public timer = null;

Test() {
  let _this = this;
  this.timer = setInterval(function() { _this.cnt++; _this.smModal.show(); }, 200);
}

Stop(){
  if(this.timer){
    clearInterval(this.timer);
    this.timer = null;
  }
  this.smModal.hide();
}
  1. Add above code to any component and start the server.
  2. Click Start Test button, a small modal will show.
  3. Click anywhere at the window, the small modal will hide, but never show again.
  4. Change the config of smModal to {backdrop: true}, and run server again.
  5. Repeat step 2 and 3, we will find several backdrops have been added.

This case comes from a situation that I want to show a modal when a message comes in, but when several messages comes in rapidly in a short time, above bugs occur.

@hkb1990
Copy link
Contributor Author

hkb1990 commented Oct 20, 2016

Setting isAnimated to false could solve this problem temporarily. But there seems no option to turn it off.

hkb1990 added a commit to hkb1990/ng2-bootstrap that referenced this issue Oct 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant