shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 242 forks source link

No Scrolling in Angular2 App with Vex Plugin after modal.confirm().open() #258

Open pcwa-ahendricks opened 7 years ago

pcwa-ahendricks commented 7 years ago

IMPORTANT: Please provide a sample using:

return this.modal
      .confirm()
      .message('Are you sure you want to leave this page?')
      // .className('default')
      .okBtn('Yes')
      .cancelBtn('Stay')
      .open()
      .then((resultPromise) => {
        return (<Promise<boolean>>resultPromise.result)
          .then((response) => response)
          .catch(() => false);
      });

Any ideas?

shlomiassaf commented 7 years ago

The demo app does not have this issue.

It's difficult to assess the issue without proper reproduction.

Please provide a plunker so I can review the steps leading to the issue.

Thank you.

zkorz commented 7 years ago

I know this is not extremely helpful because I cannot produce it consistently, but my application is also losing scrolling after the user presses "OK". It seems to happen very sporadically and maybe when I'm trying to scroll immediately after pressing OK or when my computer is thinking hard / slowing down for some reason (not sure if there's a direct connection).

The scrolling returns if I click a button to open a new modal and then click cancel.

I am using the Bootstrap plugin so it's not just for the VEX. If I manage to be able to produce it consistently I will provide code.

I am using Angular 2.4.0 and 2.0.1 of angular2-modal.

altschuler commented 7 years ago

I have this issue as well. It's happens when closing the modal takes a while (>1 second). In my case I'm doing some heavy work that takes a while to finish.

The culprit is that animationEnd$ never completes (https://github.com/shlomiassaf/angular2-modal/blob/master/src/lib/plugins/vex/modal.ts#L91) and thus the vex-open class on body is never removed, leaving the page without scrolling.

I couldn't figure out why the animation never ends, but I'm guessing it has to do with a timing issue.

I did a dirty workaround by manually removing vex-open from body when the modal closes.

zkorz commented 7 years ago

You hit it spot on @altschuler . I ran a long loop inside my "success" function and the scrolling stopped every time. Mine was intermittent because it occasionally took a long time. I am using the Bootstrap and the following line at the end of my success function fixed it:

document.body.classList.remove('modal-open')

I'm hoping that doesn't have unintended consequences.

mckinleymedia commented 7 years ago

I had the same problem. This fixed it for me, too. Thanks!

Przemyslaw-Marchewka commented 7 years ago

The same situation in my app. I had to remove modal-open from body. Thanks! Nevertheless this is nasty workaround. Is this going to be fixed ?

qwe852147 commented 7 years ago

I have same problem . It will be fixed?

zerocewl commented 7 years ago

Same problem here. Workaround works: document.body.classList.remove('modal-open')

spottedmahn commented 7 years ago

same problem here. I'm navigating away on close and it happens everytime

this.modal.alert()
    .size('sm')
    .title('My Title')
    .body('Completed')
    .open()
    .then(dialog => dialog.result)
    .then(result => {
        //return to grid
        this.router.navigateByUrl('adminHome');
    })
    //this happens if the user closes by not clicking ok
    .catch(err => {
        //return to grid
        this.router.navigateByUrl('adminHome');
    });
altschuler commented 7 years ago

Issue seems to be gone with version 3.0.1

celsomtrindade commented 7 years ago

Not for me. Still running into the same problem, where the body keeps the class modal-open. The solution to hard remove the class using document.body will work, but everywhere I have a modal I have to create a .then() just to run this code.