Skip to content

Commit 94f55e0

Browse files
Fix body scroll lock - always remove overflow/position styles when closing modal
1 parent 5cf8543 commit 94f55e0

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/js/icons.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ export async function initIconPicker() {
2626
modal.dataset.open = "false";
2727
modal.setAttribute("aria-hidden", "true");
2828

29-
// Only remove body scroll lock on desktop
30-
if (!isMobile()) {
31-
document.body.style.removeProperty('overflow');
32-
document.body.style.removeProperty('position');
33-
document.body.style.removeProperty('top');
34-
document.body.style.removeProperty('width');
29+
// Always remove body scroll lock styles (in case they were applied)
30+
document.body.style.removeProperty('overflow');
31+
document.body.style.removeProperty('position');
32+
document.body.style.removeProperty('top');
33+
document.body.style.removeProperty('width');
34+
35+
// Restore scroll position on desktop
36+
if (!isMobile() && scrollPosition > 0) {
3537
window.scrollTo(0, scrollPosition);
3638
}
3739

0 commit comments

Comments
 (0)