Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/utils/scrollUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Scroll utility functions
export function scrollToElement(id: string, offset: number = 80): void {
const el = document.getElementById(id);
if (el) { const y = el.getBoundingClientRect().top + window.scrollY - offset; window.scrollTo({ top: y, behavior: 'smooth' }); }
}

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

document.body.style.position = 'fixed';
document.body.style.top = '-' + scrollY + 'px';
document.body.style.width = '100%';
return () => { document.body.style.position = ''; document.body.style.top = ''; document.body.style.width = ''; window.scrollTo(0, scrollY); };
}

Loading