Added the scroll to top button - #659
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds floating scroll-to-top buttons to the campaigns pages, with fixed circular styling, visibility toggling after 300px of scrolling, and smooth scrolling to the page top on click. ChangesScroll-to-top interaction
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/main.js (1)
613-615: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winThrottle the scroll listener with requestAnimationFrame.
The
scrollevent fires dozens of times per second during scrolling. On the long list pages this feature targets, readingwindow.scrollYand mutatinginline styleon every event can cause noticeable jank. Wrapping the handler in arequestAnimationFrameguard is a well-known, low-cost pattern that eliminates redundant work.⚡ Proposed fix: rAF-throttled scroll handler
- window.addEventListener('scroll', () => { - scrollBtn.style.display = window.scrollY > 300 ? 'block' : 'none'; - }); + let ticking = false; + window.addEventListener('scroll', () => { + if (ticking) return; + ticking = true; + requestAnimationFrame(() => { + scrollBtn.style.display = window.scrollY > 300 ? 'block' : 'none'; + ticking = false; + }); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/main.js` around lines 613 - 615, Throttle the scroll listener around the scrollBtn visibility update using a requestAnimationFrame guard: schedule at most one frame while scrolling, read window.scrollY and update scrollBtn.style.display inside that frame, then clear the guard so the next scroll event can schedule another frame.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/theme.css`:
- Around line 1309-1321: Update the .btn-scroll-top styles to define a visible
background-color, contrasting text color, and box-shadow. Add :hover and
:focus-visible states with clear visual feedback, ensuring keyboard users
receive a visible focus indicator while preserving the existing positioning and
sizing.
---
Nitpick comments:
In `@frontend/main.js`:
- Around line 613-615: Throttle the scroll listener around the scrollBtn
visibility update using a requestAnimationFrame guard: schedule at most one
frame while scrolling, read window.scrollY and update scrollBtn.style.display
inside that frame, then clear the guard so the next scroll event can schedule
another frame.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f8c39cae-8d86-401a-8bc8-bd8bc9786ebd
📒 Files selected for processing (3)
frontend/campaigns.htmlfrontend/main.jsfrontend/theme.css
Pull Request
🔗 Related Issue
Closes #473
📝 Summary of Changes
I have added the scroll-to-top button
🏷️ Type of Change
✅ Checklist
Summary by CodeRabbit