Skip to content

fix: preserve scroll position when locking body#371

Open
wanxiankai wants to merge 1 commit into
uidotdev:mainfrom
wanxiankai:fix/preserve-body-scroll-lock-position
Open

fix: preserve scroll position when locking body#371
wanxiankai wants to merge 1 commit into
uidotdev:mainfrom
wanxiankai:fix/preserve-body-scroll-lock-position

Conversation

@wanxiankai

Copy link
Copy Markdown

Summary

  • preserve the current window scroll position when useLockBodyScroll mounts
  • lock the body with fixed positioning while keeping the viewport at the same visual offset
  • restore the previous inline body styles and scroll position on cleanup

Fixes #342.

Verification

  • node --check index.js
  • node -e "import('./index.js').then((m) => { if (typeof m.useLockBodyScroll !== 'function') process.exit(1) })"
  • temporary React dispatcher smoke test for useLockBodyScroll style restoration and scrollTo behavior

Note: npx tsc --noEmit currently fails on existing site TypeScript configuration/dependencies unrelated to this change (missing JSX config and site packages).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] useLockBodyScroll resets scroll to top

1 participant