In some situations it can happen that "restorePositionSetting" runs before "setPositionFixed" when calling "enableBodyScroll" right after "enableBodyScroll" and therefore the scroll lock is not being released due to fixed positioning on target element.
Possible fix: by wrapping restorePositionSetting logic on a requestAnimationFrame method queues the execution and prevent this issue to happen since setPositionFixed is already using requestAnimationFrame. Created a pull request with this change.
In some situations it can happen that "restorePositionSetting" runs before "setPositionFixed" when calling "enableBodyScroll" right after "enableBodyScroll" and therefore the scroll lock is not being released due to fixed positioning on target element.
Example: https://codesandbox.io/s/wizardly-sound-53xgy
Possible fix: by wrapping
restorePositionSetting
logic on arequestAnimationFrame
method queues the execution and prevent this issue to happen sincesetPositionFixed
is already usingrequestAnimationFrame
. Created a pull request with this change.