You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment the hook leaves overflow and padding-right on the target after unlocking. Even though it is a computed value from before the lock, it can change in CSS for various reasons (and not considered in future locks) and will always be overridden by inline styles. These 2 values should be reverted to the initial value if they existed inline, otherwise removed completely which will make the styles on the target the same as before the lock.
The second problem is that the global scrollbar is not part of the body, so if lockTarget is a body element scrollbarWidth will always be 0. There should be a special case for body as a target and use window.innerWidth instead of target.current.offsetWidth to get the width with the global scrollbar.
Describe the bug
overflow
andpadding-right
on the target after unlocking. Even though it is a computed value from before the lock, it can change in CSS for various reasons (and not considered in future locks) and will always be overridden by inline styles. These 2 values should be reverted to the initial value if they existed inline, otherwise removed completely which will make the styles on the target the same as before the lock.Here's an example how
tua-body-scroll-lock
does this.lockTarget
is abody
elementscrollbarWidth
will always be 0. There should be a special case forbody
as a target and usewindow.innerWidth
instead oftarget.current.offsetWidth
to get the width with the global scrollbar.To Reproduce
Codesandbox repro link
body
as a targetExpected behavior
After unlocking, the target element should have initial inline styles or no inline styles if they weren't present.
Additional context
No response
The text was updated successfully, but these errors were encountered: