📌 Description
ScrollToTop (src/shared/components/ScrollToTop.tsx) scrolls to top on route change and moves focus to #main (falling back to skip-target/body) while honoring prefers-reduced-motion, but its logic is untested.
💡 Why it matters: Route-change focus and scroll behavior is easy to regress and affects accessibility.
🧩 Requirements and context
- Test scroll-to-top on pathname change.
- Test focus moves to
#main, then skip-target, then body when targets are missing.
- Test smooth vs instant scroll under
prefers-reduced-motion.
- Test that hash-only changes are ignored.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b test/scrolltotop
2. Implement changes
- Write/modify the relevant source: minor TSDoc on
src/shared/components/ScrollToTop.tsx
- Write comprehensive tests:
src/shared/components/ScrollToTop.test.tsx
- Add documentation: inline TSDoc
- Include TSDoc doc comments
- Validate security assumptions: n/a
3. Test and commit
- Cover edge cases: missing
#main, reduced motion, hash navigation
- Include test output and security notes in the PR description.
Example commit message
test(scrolltotop): cover scroll and focus fallbacks
✅ Acceptance criteria
🔒 Security notes
None.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
ScrollToTop(src/shared/components/ScrollToTop.tsx) scrolls to top on route change and moves focus to#main(falling back to skip-target/body) while honoringprefers-reduced-motion, but its logic is untested.🧩 Requirements and context
#main, then skip-target, then body when targets are missing.prefers-reduced-motion.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
src/shared/components/ScrollToTop.tsxsrc/shared/components/ScrollToTop.test.tsx3. Test and commit
npm run test#main, reduced motion, hash navigationExample commit message
✅ Acceptance criteria
🔒 Security notes
None.
📋 Guidelines