Skip to content

feature added -scroll-to-top#453

Open
Vaibhav-221 wants to merge 2 commits into
piyushdotcomm:mainfrom
Vaibhav-221:feat/438/scroll-to-top
Open

feature added -scroll-to-top#453
Vaibhav-221 wants to merge 2 commits into
piyushdotcomm:mainfrom
Vaibhav-221:feat/438/scroll-to-top

Conversation

@Vaibhav-221

@Vaibhav-221 Vaibhav-221 commented Jun 2, 2026

Copy link
Copy Markdown

Closes

Closes #438

📌Summary

This PR adds a reusable Scroll to Top button and mounts it globally so users can quickly return to the top of long pages from anywhere in the app.

What Changed

  • Added a new ScrollToTopButton UI component.
  • Mounted the component in the root layout/app wrapper so it is available across all pages.
  • Added scroll-based visibility so the button only appears after the user scrolls down.
  • Added smooth scroll-to-top behavior on click.
  • Styled the button with Editron’s red accent color, rounded shape, transition, and hover interaction.
  • Added accessible labeling with aria-label="Scroll to top".

Why?

Long pages can require a lot of manual scrolling once users reach deeper sections like pricing, content blocks, or the footer. This gives users a quick, familiar way to return to the top and improves navigation across the site.

Screen Recording

Desktops Viewport

Screen.Recording.2026-06-02.223956.mp4

Mobile viewport

Screen.Recording.2026-06-02.224046.mp4

Testing

  • Verified the button is hidden when the page is near the top.
  • Verified the button appears after scrolling down.
  • Verified clicking the button smoothly scrolls back to the top.
  • Verified the button hides again after returning near the top.
  • Verified the button is available across multiple pages, not just the landing page.
  • Verified hover and transition states work as expected.

Accessibility

  • Added aria-label="Scroll to top" for screen reader users.
  • Prevented interaction while the button is hidden.

Summary by CodeRabbit

  • New Features

    • Added a scroll-to-top button with a visual progress indicator that appears as you scroll.
  • Style

    • Adjusted dashboard page container classes (removed overflow restriction) and updated top-level markup to allow expected page overflow/scroll behavior.
  • Chores

    • Integrated the new scroll-to-top control into the main app layout so it appears across pages.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b3b5e305-9cdd-4d61-bc7a-1adc602466d8

📥 Commits

Reviewing files that changed from the base of the PR and between bdaea98 and 673c782.

📒 Files selected for processing (1)
  • modules/dashboard/components/scroll-to-top-button.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • modules/dashboard/components/scroll-to-top-button.tsx

Walkthrough

Adds a new client-side ScrollToTopButton component that listens to scroll events, shows a fixed circular button with a conic-gradient progress indicator after a threshold, and scrolls the page to the top on click. The component is imported into RootLayout; the dashboard root JSX is wrapped in a fragment and overflow-hidden is removed.

Changes

Scroll to Top Button Implementation and Integration

Layer / File(s) Summary
ScrollToTopButton component implementation
modules/dashboard/components/scroll-to-top-button.tsx
Client component declared with "use client", uses refs and useEffect to attach passive scroll listeners to window and document, computes scroll progress, updates wrapper/button inline styles (opacity, pointer-events, translateY, conic-gradient background), toggles accessibility attributes, implements a smooth scroll-to-top handler with fallback, and cleans up listeners on unmount.
Layout integration and dashboard markup
app/layout.tsx, app/dashboard/page.tsx
Imports and renders ScrollToTopButton inside RootLayout alongside top-level components; dashboard page return JSX now uses a fragment wrapper and the root container has overflow-hidden removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I watched the page tumble, pixels in flight,
A button arose in the corner — a beacon of light,
Spin the ring, press the chevron, up we all hop,
Smooth as a carrot breeze, back to the top! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive Title is vague and uses non-descriptive phrasing with formatting inconsistencies ('feature added -scroll-to-top'). Use a clearer, more descriptive title such as 'Add scroll-to-top button component' or 'Implement floating scroll-to-top button' to better convey the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed Description is comprehensive and follows the template structure with clear sections covering what changed, why it changed, testing, and accessibility considerations.
Linked Issues check ✅ Passed The code changes successfully implement all primary objectives from issue #438: ScrollToTopButton component with visibility threshold [#438], smooth scroll behavior [#438], fixed positioning [#438], fade-in transitions [#438], Editron red styling [#438], and accessibility features [#438].
Out of Scope Changes check ✅ Passed All changes are directly related to the scroll-to-top feature: new component, root layout integration, and minimal dashboard layout adjustments to support the feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

👋 Thanks for opening a PR, @Vaibhav-221!

Your PR has entered the 🚦 PR Review Pipeline.

Standard PR detected — your PR will follow the standard review pipeline.


What happens next

Stage Reviewer Checks
Stage 1 — Automated Validation 🤖 Bot DCO · Format · AI/Slop · Duplicate
Stage 2 — Human Review 👥 Maintainer Code + Quality Review
Stage 3 — PA / Maintainer Review 🔑 Project Admin Final Merge Decision

A pipeline status comment will appear below and update automatically as your PR progresses.


While you wait

  • Sign all commits (git commit -s)
  • Link your issue (Closes #123)
  • Use a feature branch (not main)
  • Avoid unrelated changes

This comment is posted only once.

@Vaibhav-221

Copy link
Copy Markdown
Author

Hii @piyushdotcomm, review the PR!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
app/layout.tsx (1)

11-11: ⚡ Quick win

Move this into a shared UI location before wiring it into the root layout.

Since this is rendered globally, keeping it under modules/dashboard/components makes the app shell depend on a dashboard feature module. Moving it to a shared UI path will keep the boundary clean and match the intended ownership of this component.

Also applies to: 92-92

🤖 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 `@app/layout.tsx` at line 11, The ScrollToTopButton import in app/layout.tsx
currently pulls from modules/dashboard/components which makes the global layout
depend on the dashboard feature; move the component file into a shared UI
location (e.g., components/ui or shared/ui) and update the import in
app/layout.tsx (the existing import of ScrollToTopButton and the other
occurrence at line 92) to point to the new shared path; ensure the component
export name remains ScrollToTopButton and adjust any internal relative imports
inside the component after the move.
🤖 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 `@modules/dashboard/components/scroll-to-top-button.tsx`:
- Around line 25-27: The button's hidden state is only visual so it remains
focusable; update the ScrollToTopButton component (use the wrapperRef/button
element and the visibility state used for setting style.opacity/transform) to
also remove it from the tab order and assistive technology when hidden by adding
tabindex={-1}, aria-hidden="true", and disabled={true} (or conversely remove
those attributes when visible), or alternatively render the button conditionally
from React state so it is not in the DOM when not visible; apply the same change
for the second occurrence referenced around lines 65-69.
- Around line 21-28: Replace the immediate-visibility check (visible = scrollTop
> 0) with a threshold-based check using a reveal threshold (e.g., use a prop or
constant named revealThreshold, defaulting to 300) so the button only becomes
visible when scrollTop > revealThreshold; update the visible assignment and keep
the existing wrapperRef style updates (opacity, pointerEvents, transform,
background) intact, and if the component doesn't yet accept a revealThreshold
prop add one to the component signature and fallback to 300 when undefined.
- Around line 45-51: The scrollToTop function currently calls
window.scrollTo({behavior: "smooth"}) but then immediately forces
document.documentElement.scrollTop and document.body.scrollTop to 0 which
cancels the smooth animation; change scrollToTop to only perform the immediate
writes as a fallback when smooth scrolling is not supported: detect support with
a capability check (e.g., CSS && CSS.supports('scroll-behavior','smooth') or
feature-test whether window.scrollTo accepts a behavior option) and if supported
call window.scrollTo({top:0, behavior:'smooth'}), otherwise set
document.documentElement.scrollTop = 0 and document.body.scrollTop = 0; remove
the unconditional writes so smooth scrolling is not short-circuited.

---

Nitpick comments:
In `@app/layout.tsx`:
- Line 11: The ScrollToTopButton import in app/layout.tsx currently pulls from
modules/dashboard/components which makes the global layout depend on the
dashboard feature; move the component file into a shared UI location (e.g.,
components/ui or shared/ui) and update the import in app/layout.tsx (the
existing import of ScrollToTopButton and the other occurrence at line 92) to
point to the new shared path; ensure the component export name remains
ScrollToTopButton and adjust any internal relative imports inside the component
after the move.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a975654-a0ab-4d36-ac82-2d858931410a

📥 Commits

Reviewing files that changed from the base of the PR and between f12b223 and bdaea98.

📒 Files selected for processing (3)
  • app/dashboard/page.tsx
  • app/layout.tsx
  • modules/dashboard/components/scroll-to-top-button.tsx

Comment thread modules/dashboard/components/scroll-to-top-button.tsx
Comment thread modules/dashboard/components/scroll-to-top-button.tsx
Comment thread modules/dashboard/components/scroll-to-top-button.tsx Outdated

@Vaibhav-221 Vaibhav-221 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As per suggestion's, all issue resolved.

@Vaibhav-221

Copy link
Copy Markdown
Author

@piyushdotcomm, review the PR!

@Vaibhav-221

Copy link
Copy Markdown
Author

@piyushdotcomm, Kindly look into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add "Scroll to Top" floating button that appears on scroll and smoothly returns user to top of page

1 participant