Skip to content

fix: share default and explicit body scroll locks - #819

Open
feritcemkahraman wants to merge 1 commit into
react-component:masterfrom
feritcemkahraman:fix/shared-body-scroll-lock
Open

feritcemkahraman wants to merge 1 commit into
react-component:masterfrom
feritcemkahraman:fix/shared-body-scroll-lock

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Oct 8, 2026 •

Copy link
Copy Markdown

new ScrollLocker() and new ScrollLocker({container: document.body}) operate on the same DOM element, but their lock records are currently compared as undefined versus document.body. Locking both overwrites the original style cache; after both unlock, the body's original overflow remains replaced with hidden.

Compare the effective containers (falling back to document.body) consistently when sharing, caching, and releasing locks. Add regressions for both lock orders, checking that the body stays locked until the final release and then restores its original overflow.

Validation:

  • All 7 ScrollLocker tests pass, including the two new regressions.
  • Before the source fix, the existing 5 tests pass and both new tests fail.
  • Formatting and git diff --check pass.
  • Tests were executed with a local Jest/TypeScript/jsdom harness; the full repository lint/build/test suite was not run.

Summary by CodeRabbit

  • Bug 修复
    • 修正不同滚动锁同时作用于页面主体时的处理:释放其中一个锁后,页面仍保持锁定;全部锁释放后,滚动状态和相关效果均恢复。

@vercel

vercel Bot commented Oct 8, 2026

Copy link
Copy Markdown

@feritcemkahraman is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 32440202-9eb2-499b-8874-72fd6201f042
📥 Commits

Reviewing files that changed from the base of the PR and between 993255e and 99a318b.

📒 Files selected for processing (2)
  • src/Dom/scrollLocker.ts
  • tests/scrollLocker.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

ScrollLocker 在容器锁定和解锁时,将未指定容器的默认值 document.body 与显式指定的 document.body 视为同一容器。新增测试覆盖两种锁定顺序下的共享锁状态。

Changes

Body 容器锁定

Layer / File(s) Summary
统一生效容器的锁状态判断
src/Dom/scrollLocker.ts, tests/scrollLocker.test.ts
锁定、锁复用和解锁检查均按生效容器比较。新增参数化测试,验证任一实例先解锁时 overflow 仍为 hidden,且所有实例解锁后恢复 auto 并移除效果类。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 99a31

The body lock remains in place until the final release, and no outstanding issue prevents merging after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“fix: share default and explicit body scroll locks”准确概括了主要变更:统一默认容器与显式指定 document.body 的滚动锁。标题简洁、具体,且与代码和测试变更一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

兔子轻敲滚动锁,
默认 body 与显式相逢。
一只先退,隐藏仍在,
两只都退,样式归还。
耳尖摇摇,测试通过。

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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