Skip to content

fix(modals): tie body-scroll lock to open state#109

Merged
dmnyc merged 1 commit into
masterfrom
fix/scroll-lock-leak
Apr 27, 2026
Merged

fix(modals): tie body-scroll lock to open state#109
dmnyc merged 1 commit into
masterfrom
fix/scroll-lock-leak

Conversation

@dmnyc

@dmnyc dmnyc commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Modals calling useLockScroll() unconditionally were stacking a redundant body-scroll lock when nested inside another locked modal. The worst case: WalletBackupDialog is mounted unconditionally inside WalletUnlocked and was locking scroll the whole time the wallet was open.
  • On unmount, the cleanup race would leave body.style.overflow stuck on "hidden" — scrolling stayed disabled after the wallet (or onboarding overlay, etc.) closed.
  • Fix: pass the open flag to every useLockScroll caller so its lock lifecycle is tied to visible state, not mount state.

Test plan

  • tsc --noEmit clean
  • biome check clean on touched files
  • Open wallet (locked) → unlock → close → page scroll works
  • Open onboarding → cancel → page scroll works
  • Open Nostr event modal → close → page scroll works
  • Open wallet → click Backup → close backup dialog → wallet still scrollable; close wallet → page scroll works

Modals that called useLockScroll() unconditionally would stack a
redundant lock when nested inside another locked modal (notably
WalletBackupDialog inside WalletUnlocked), and the cleanup race on
unmount left body overflow stuck on "hidden" — scrolling stayed
disabled after the wallet closed.

Pass the open flag to every useLockScroll caller so the lock
lifecycle tracks visible state instead of mount state.
@dmnyc
dmnyc merged commit 1249f36 into master Apr 27, 2026
3 checks passed
@dmnyc
dmnyc deleted the fix/scroll-lock-leak branch April 27, 2026 23:04
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.

1 participant