feat(utils): add scroll utilities#14
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/utils/scrollUtils.ts">
<violation number="1" location="src/utils/scrollUtils.ts:8">
P2: Unlocking scroll clears pre-existing body inline styles instead of restoring previous values, which can break layout state after closing a modal.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| } | ||
|
|
||
| export function lockScroll(): () => void { | ||
| const scrollY = window.scrollY; |
There was a problem hiding this comment.
P2: Unlocking scroll clears pre-existing body inline styles instead of restoring previous values, which can break layout state after closing a modal.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/scrollUtils.ts, line 8:
<comment>Unlocking scroll clears pre-existing body inline styles instead of restoring previous values, which can break layout state after closing a modal.</comment>
<file context>
@@ -0,0 +1,14 @@
+}
+
+export function lockScroll(): () => void {
+ const scrollY = window.scrollY;
+ document.body.style.position = 'fixed';
+ document.body.style.top = '-' + scrollY + 'px';
</file context>
Scroll-to-element and scroll lock for modals.
Summary by cubic
Adds simple scroll utilities to improve navigation and modal behavior. Enables smooth scroll to targets and prevents background scrolling when overlays are open.
Written for commit 043cd27. Summary will update on new commits.