eBay / nice-modal-react

A modal state manager for React.
https://ebay.github.io/nice-modal-react
MIT License
1.96k stars 109 forks source link

bug: 当路由发生变化时,弹窗不会自动销毁 #114

Closed zzyouyou closed 9 months ago

zzyouyou commented 1 year ago

当在页面中打开一个弹窗之后,如果路由返回上一级或者前进到下一级时,窗口不会自动销毁

supnate commented 1 year ago

It's not a bug. For such case use declarative way instead: https://opensource.ebay.com/nice-modal-react/#declarative .

zzyouyou commented 1 year ago

谢谢你的回复,不过好像它并没有生效,在路由后退时依然不会消失,即使是在https://opensource.ebay.com/nice-modal-react/#declarative .这个例子中。请问是故意这样设计的嘛?

supnate commented 1 year ago

yes it's by design. can you please create a example to reproduce? With https://codesandbox.io .

zzyouyou commented 1 year ago

抱歉,我尝试了,但是却无法在codesandbox复现这个情况。但是在你们提供的demo中是可以复现的。过程如下: 1、打开网页https://opensource.ebay.com/nice-modal-react/#promise 2、切换到https://opensource.ebay.com/nice-modal-react/#declarative 3、在declarative示例中点击Show Modal 4、点击浏览器的返回上一级按钮,然后发现弹窗没有自动消失。 再一次感谢您的回复,我对此比较好奇,因为我发现antd的Modal似乎没有这种情况。

supnate commented 9 months ago

Oh, plz see the updated declarative sample, it was not the correct one. https://opensource.ebay.com/nice-modal-react/#declarative

ArturKustyaev commented 7 months ago

Oh, plz see the updated declarative sample, it was not the correct one. https://opensource.ebay.com/nice-modal-react/#declarative

Strange, it turns out you need to use a declarative approach in most cases? Because when the application path changes, it is expected that the modal window should close