fix: use replaceState to prevent scroll jump on modal close#200
fix: use replaceState to prevent scroll jump on modal close#200rdmueller merged 1 commit intoLLM-Coding:mainfrom
Conversation
Using history.replaceState instead of setting window.location.hash avoids triggering hashchange, which would re-render the page and scroll to top. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ÜberblickDie Änderungen
Geschätzter Code Review-Aufwand🎯 2 (Einfach) | ⏱️ ~10 Minuten Möglicherweise verwandte PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
website/src/components/anchor-modal.js (1)
3-3:⚠️ Potential issue | 🟡 MinorUnbenutzten Import entfernen
getScrollBeforeModalwird hier nicht verwendet und sollte aus dem Import entfernt werden.Diff-Vorschlag
-import { getRouteBeforeModal, getScrollBeforeModal } from '../utils/router.js' +import { getRouteBeforeModal } from '../utils/router.js'As per coding guidelines
website/src/**/*.js: Check for: security issues, unused variables, proper error handling.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@website/src/components/anchor-modal.js` at line 3, Remove the unused import getScrollBeforeModal from the import statement in website/src/components/anchor-modal.js (leave getRouteBeforeModal), search the file for any remaining references to getScrollBeforeModal and remove or replace them if present, and run the linter/ESLint to confirm no unused-import warnings remain and that the module still builds correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@website/src/components/anchor-modal.js`:
- Line 3: Remove the unused import getScrollBeforeModal from the import
statement in website/src/components/anchor-modal.js (leave getRouteBeforeModal),
search the file for any remaining references to getScrollBeforeModal and remove
or replace them if present, and run the linter/ESLint to confirm no
unused-import warnings remain and that the module still builds correctly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 7837bb60-3109-407d-93aa-11f1a556be91
📒 Files selected for processing (1)
website/src/components/anchor-modal.js
Summary
Closing the anchor modal caused the page to scroll to top because
window.location.hash = ...triggered ahashchangeevent, which re-rendered the page.Fix: Use
history.replaceStateto update the URL silently — the modal hides, the page stays exactly where it was.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Versionshinweise