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
Opening the drawer and then opening the modal from the drawer in combination with React Router sets the overflow: hidden on <body> element #21539
Comments
I am not sure if this could be fully reproduced in CodeSandbox so you can clone and run my simple demo project here (https://github.com/bouchja1/ant-react-router-bug). Btw. if I set:
...I am temporarily ok with this hack... but should there occur any problem with this hack? |
Or probably better solution with
Placed before router switch. It wont make a background scroll while a modal is opened. |
Seeing the same issue, even without navigating to another page - if you dismiss a modal inside a drawer component, it will set { overflow: hidden; } on the html body. You can also do |
Hi @AceNorth, I have the same issue as you mentioned after I have upgraded to Ant v4. overflow: hidden even without navigation to another page. So the temporary solution with I did not see any comments from Ant team. Don't know if this could be considered as a bug... or this is an intention. |
@bouchja1 It should still work, I think - you don't need to navigate to another page to call that function. I've added it as an |
Then the whole page lost scroll bar. |
这啥鬼问题啊,,为什么点 router 会加 overflow ? |
单个 overflow: hidden 应该是 modal 里加的。。。抽屉是加overflow: hidden; touch-action: none; |
https://github.com/react-component/dialog/blob/master/src/Dialog.tsx#L129, 这时的问题,,,那个谁还在给你们搞没,,@afc163 |
this. inTransition 干吊用的?? |
cc @shaodahong |
不对,,好像在 willunmount 之前刷了遍,,我晚上看下吧。。 |
https://github.com/react-component/dialog/blob/master/src/Dialog.tsx#L150, 这里的问题,,这个加着干啥用的,是为了什么功能??@shaodahong |
如果是 1 的话不需要加 hidden 啊,前面的会处理的啊,leave 不是为了关闭吗??咋还放个开启的?? |
|
这个 issue 的核心问题是用了 openCount 来判断是不是 effect,而 drawer 只有在某些情况下才会是 effect |
不对,,抽屉打开的时候,,openCount 就是 1 了,,,再开 modal 时, openCount 就是 2 了,,那关闭 modal 时就会触发 openCount =1 的问题了,,所以在关闭时要必须是 close 状态的,,现在关闭时会触发 open 的状态 |
加了个判断。。 |
我会同时判断 |
leave 里只管理关闭状态,,关闭状态必须在 openCount 为 0 时才触发... |
|
这个不应该放在这里,,不是所有页面都会有 scroll 的 |
Modal 和 Drawer 都公用了这个,放在最底层没什么问题吧 |
是 openCount 的问题,openCount 不能作为 effect 的判断,要单独拉出来一个 effectCount 这种 |
我感觉是 overflow 和 scrollEffect 的方法你混在一起了的问题,,,应该分开,drawer 里的 overflow 时内部实现了的。。。 |
Similar issue: #21894 |
还有,,我上面的修复的逻辑也没错,,,animateLeave 时只管 openCount 为 0 时去切换 scrollEffect 的状态。。。 |
想了一下,,放在一起好像也可以,,如果没有滚动条,,都不需要设 overflow: hidden,,先就放一起吧,我把 drawer 里的删了。。主要问题就是 animateLeave 时没做判断。。。 |
可以试试,后期还是要解决 |
你看吧,,这个全权交给你了。。。 |
reinstall antd |
Facing similar issue. Is there any alternative fix? Using antd v3 which uses rc-dialog version of ~7.6 as its dependency |
Yea I am having the same issue. Do we know if/when a fix will be included in an upcoming release? |
It is still happening in version 4.8.4. |
Still happened to me today. solved with afterClose={document.body.removeAttribute('style')} |
我也遇到了这个问题 afterClose={()=>{ 还必须使用setTimeout 才能重现滚动条 |
|
Reproduction link
Steps to reproduce
overflow: hidden;
touch-action: none;
} is set correctly on element because we have opened a Drawer component
What is expected?
When both drawer and modal components are closed and I am linked to a different place in my single-page web app, I will be able to scroll a page.
What is actually happening?
When I open drawer component and then open modal component inside the drawer component, close both and am linked to a different place in my single-page web app, scrolling is not working because { overflow: hidden; } style is set to html body element
Please, is there any "hack" or something similar to make it work?
The text was updated successfully, but these errors were encountered: