single-spa / single-spa-layout

Layout engine for single-spa applications
MIT License
78 stars 31 forks source link

cancelNavigation() event is not working properly , removes the app from DOM #180

Closed deepan094 closed 1 year ago

deepan094 commented 2 years ago

The issue is that when tried to cancel navigation from /app1 to /app2 . It prevents from navigating to /app2 but ( /app1) is removed from the DOM . URL remains /app1

"single-spa": "5.9.4", "single-spa-layout": "2.1.0",

Code :

_listner(ev){
    if (
      new URL(ev.detail.oldUrl).pathname === '/app1'
    ) {
       if (confirm('Are you sure you want to go back?')) {
          console.log('Yes');
        } else {       
          ev.detail.cancelNavigation();
        }
    }
}
    window.addEventListener(
      'single-spa:before-routing-event',
      this._listner
    );

Any suggestions/advice would be greatly appreciated! @joeldenning Thank you!

malthoff commented 1 year ago

Experiencing the same. It removes the app from the DOM, even the used framework does not get informed (like unMount or something). This is a huge issue, how can I upvote?

joeldenning commented 1 year ago

Resolved in #190, released in https://github.com/single-spa/single-spa-layout/releases/tag/v2.1.1