Reproduction link
Steps to reproduce
对照:
1.点击open1按钮,关闭open1模态框,重复,dom均被销毁
2.点击open2按钮,关闭open2模态框,重复,dom有时被销毁,大多数情况下还是存在,存在就会引起页面再点击无任何反应,点击都点在了弹出层上
2-1.注释掉ConfigProvider包裹,只保留Modal同1,没有问题。
What is expected?
dom被销毁
What is actually happening?
dom有时被销毁,大多数情况下还是存在
| Environment | Info |
| ------------ | ------------ |
| antd | 5.17.0 |
| React | 18.3.1 |
| System | macOS 14.4.1 |
| Browser | Chrome 126.0.6478.127 |
定位问题应该就是ConfigProvider的问题,注释掉就可,但是嵌套使用文档也是这样使用的
6条答案
按热度按时间kkbh8khc1#
Start a new pull request in StackBlitz Codeflow .
wxclj1h52#
看起来是没有动画导致失去了结束态
mxg2im7a3#
When using destroyonClose is modal instance suppose to be unmounted and removed from the DOM? I think I had an issue where I had a react hook form in a modal and after closing the modal and reopen it the previous value was still there 🫨
lmyy7pcs4#
I can relate. I'm experiencing the same problem. I'm passing the
destroyOnClose
prop to theModal
component, I close it and re-open it and data are still here; the state contained in the modal have its last value kept in memory. But it is kind of weird because it seems unmounted from the DOM (except if there are some portals involved), but inner data are not re-initialized.lp0sw83n5#
The destroyOnClose is meant to destroy the child components only right? Then in my case my react hook form useForm is set on the modal level therefore might be normal that form data remains there after re open. But I felt like deatryOnClose should destroy the entire modal instance rather than the child only .. thought?
ipakzgxi6#
@AsuraKev maybe that's what you are looking for. But it does not reflect the issue I've though.