Skip to content

Commit d3d9192

Browse files
committed
Fix bug where nav toggle can reset theme settings.
There is code in the function to lock the scroll which adds inline styles to the body element. These styles are removed by clearing out all the inline styles when the unlock function is called—but also any inline styles are removed which interferes with the theme settings variables—by being more explicit about which inline styles are removed, this bug can be avoided. Now, only those styles needed for locking/unlocking scroll are removed when that function is called.
1 parent 7c6ccfb commit d3d9192

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/scroll-lock.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,11 @@ export default {
149149
// revert the old scroll position
150150
advancedUnlock(targetElement);
151151
} else {
152-
// remove all inline styles
153-
document.body.style.cssText = '';
152+
// remove all inline styles added by the `simpleLock` function
153+
document.body.style.removeProperty('overflow');
154+
document.body.style.removeProperty('top');
155+
document.body.style.removeProperty('position');
156+
document.body.style.removeProperty('width');
154157

155158
// restore scrolled Y position after resetting the position property
156159
window.scrollTo(0, Math.abs(scrolledClientY));

0 commit comments

Comments
 (0)