Skip to content

feat(utils): add scroll utilities#14

Merged
maitamdev merged 1 commit into
mainfrom
feat/scroll-utils
Mar 4, 2026
Merged

feat(utils): add scroll utilities#14
maitamdev merged 1 commit into
mainfrom
feat/scroll-utils

Conversation

@maitamdev
Copy link
Copy Markdown
Owner

@maitamdev maitamdev commented Mar 4, 2026

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.

  • New Features
    • scrollToElement(id, offset=80): smooth scroll to an element, with header-safe offset.
    • lockScroll(): freezes body scroll and returns an unlock function to restore position.

Written for commit 043cd27. Summary will update on new commits.

@maitamdev maitamdev merged commit 42164b2 into main Mar 4, 2026
1 of 2 checks passed
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dhv-guiding-light Building Building Preview, Comment Mar 4, 2026 7:09pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 4, 2026

Warning

Rate limit exceeded

@maitamdev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 05a21c3b-02bf-4147-8fb3-eac75a2ca087

📥 Commits

Reviewing files that changed from the base of the PR and between e2c7806 and 043cd27.

📒 Files selected for processing (1)
  • src/utils/scrollUtils.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/scroll-utils

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

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

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/utils/scrollUtils.ts
}

export function lockScroll(): () => void {
const scrollY = window.scrollY;
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

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