Skip to content

Back to top component created and added #202

Closed
Souradeep858 wants to merge 3 commits into
kunalverma2512:mainfrom
Souradeep858:main
Closed

Back to top component created and added #202
Souradeep858 wants to merge 3 commits into
kunalverma2512:mainfrom
Souradeep858:main

Conversation

@Souradeep858

@Souradeep858 Souradeep858 commented Jun 15, 2026

Copy link
Copy Markdown

📌 Pull Request Summary

🔗 Related Issue

Closes #

Closes #200

📝 Description

Provide a clear and concise summary of the changes made in this pull request.

Implemented a Back to Top button component to improve navigation and user experience across the website. The button appears when users scroll down the page and allows them to smoothly return to the top with a single click.

Changes Made

1.Created a reusable BackToTop component using React and Tailwind CSS.
2.Added scroll detection logic to show/hide the button based on page position.
3.Implemented smooth scrolling behavior.
4.Integrated the component into the application layout for global availability.
5.Styled the button with a modern floating design and hover effects.

Motivation

Explain why these changes were necessary and what problem they solve.

Users had no quick way to navigate back to the top of long pages. This enhancement improves usability and accessibility by providing an intuitive navigation shortcut.


🚀 Type of Change

Select all that apply:

  • Bug Fix
  • [.] New Feature
  • [.] Enhancement
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • DevOps / Tooling
  • Other

🧪 Testing

Verification

  • [.] Tested Locally
  • Existing Tests Passed
  • New Tests Added
  • No Testing Required

Test Details

Describe how the changes were tested and verified.

Verified that:

The button remains hidden when the page is at the top.
The button appears after scrolling down.
Clicking the button smoothly scrolls the page back to the top.
The component works across different pages and screen sizes.

📸 Screenshots / Demo (If Applicable)

Attach screenshots, GIFs, or recordings that help demonstrate the changes.


✅ Checklist

  • [.] I have read and followed the contribution guidelines.
  • [.] I have self-reviewed my changes.
  • [.] My changes are limited to the scope of this issue.
  • Documentation has been updated where necessary.
  • [.] No unnecessary files or unrelated changes have been included.
  • [.] The related issue has been linked correctly.
  • [.] All applicable testing and validation steps have been completed.

📚 Additional Notes

Add any additional information that may help reviewers.

Summary by CodeRabbit

  • New Features
    • Added a global “Back to Top” floating button that appears after scrolling down.
    • Users can click the button to smoothly return to the top of the page, available across all routed pages.

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

@Souradeep858 is attempting to deploy a commit to the Kunal Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Souradeep858, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 14 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d34177f-8e2f-49e4-ad3e-94970c506682

📥 Commits

Reviewing files that changed from the base of the PR and between 123f89f and 512fbce.

📒 Files selected for processing (1)
  • frontend/src/components/shared/Backtotop.jsx
📝 Walkthrough

Walkthrough

A new BackToTop shared React component is added that listens to window.scroll, shows a fixed-position button after 300px of scroll, and smoothly scrolls to the top on click. The component is imported and rendered globally in App.jsx.

Changes

Back to Top Feature

Layer / File(s) Summary
BackToTop component implementation
frontend/src/components/shared/Backtotop.jsx
New functional component with visible state initialized to false, useEffect scroll listener that sets visible when window.scrollY > 300 and cleans up on unmount, scrollToTop click handler that calls window.scrollTo({ top: 0, behavior: 'smooth' }), and a fixed-position button that renders only when visible is true, displaying an ArrowUp icon with an aria-label of "Back to top".
App-level wiring
frontend/src/App.jsx
Imports BackToTop and renders it inside the global layout, making it available across all routed pages.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

  • #200 (Adding back to top button for better navigation): This PR directly implements the proposed floating back-to-top button with the 300px scroll threshold, smooth scrolling via window.scrollTo({ top: 0, behavior: 'smooth' }), and fixed bottom-right positioning described in that issue.

Suggested labels

type:feature, Frontend, UI/UX, enhancement, responsive, type:accessibility

Poem

🐇 Hop, hop, scroll down the page I go,
Past headers and footers, row by row,
But wait — an arrow appears in sight!
One click sends me back to the top just right.
The rabbit approves this smooth little feat! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Back to top component created and added' accurately summarizes the main change, which is the creation and integration of a new BackToTop component.
Description check ✅ Passed The PR description includes all major sections from the template with details on motivation, changes made, testing verification, and properly filled checklist items.
Linked Issues check ✅ Passed The implementation satisfies all core requirements from issue #200: scroll threshold detection (>300px), smooth scrolling, bottom-right positioning, responsiveness, accessibility (aria-label), design consistency, and proper event listener management.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the Back to Top feature implementation: the new component file and integration into App.jsx. No unrelated modifications or unnecessary files are included.

✏️ 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

Copy link
Copy Markdown

🎉 Welcome to CodeLens — Thank You for Your Contribution!

Hey @Souradeep858! 👋

We are genuinely excited to have you here. Every single PR — big or small — makes CodeLens better, and yours is no exception. Take a moment to review the checklist below to help us merge your work quickly and smoothly.

✅ Before Requesting a Review

  • Keep code clean, readable, and consistent with the existing codebase
  • Avoid unrelated or unnecessary file changes
  • Make sure the UI is fully responsive across all device sizes
  • Attach screenshots or a short screen recording for any UI changes
  • Resolve all merge conflicts before marking the PR as ready
  • Do not submit AI-generated, copy-pasted, or low-effort implementations

💬 Join Our Community Channel — This is Mandatory

Being part of our communication channel is compulsory for all contributors, not optional.

📡 Join the CodeLens Matrix Channel

Why join? This is where all important announcements, PR review updates, contribution discussions, and maintainer decisions happen in real time. Contributors who are not in the channel regularly miss critical context and updates, which often leads to duplicated or misaligned work. Staying connected here is what keeps the community strong and your contributions impactful.


We are rooting for you! If you have any questions, drop them in the channel or comment right here on this PR. Let's build something great together. 🚀✨

@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

🤖 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/src/components/shared/Backtotop.jsx`:
- Around line 7-15: The toggleVisibility function in the useEffect hook is only
called when a scroll event occurs, leaving the button in a stale state on
initial render if the page has already scrolled past 300px. Call the
toggleVisibility function immediately within the useEffect before adding the
event listener to ensure the button visibility is correctly set based on the
current scroll position when the component first mounts.
- Around line 25-39: The button element in the Backtotop component remains
keyboard-focusable even when hidden because pointer-events-none only prevents
mouse interactions, not keyboard focus. Add a disabled attribute or
tabIndex={-1} to the button that is conditionally applied based on the visible
state: when visible is false, either set disabled={true} or tabIndex={-1} to
remove the button from the keyboard tab order and prevent it from being
accidentally focused.
- Line 2: The Backtotop component imports FaArrowUp from react-icons/fa6, but
react-icons is not declared as a dependency in the frontend package
configuration. To fix this, either add react-icons to the frontend dependencies
in package.json, or replace the import statement in Backtotop.jsx to use
lucide-react (which is already a declared dependency) instead, updating the icon
reference from FaArrowUp to the corresponding lucide-react arrow icon (such as
ArrowUp).
🪄 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

Run ID: f7299fa7-02e7-4183-9722-805232b16fb9

📥 Commits

Reviewing files that changed from the base of the PR and between 45268d8 and a79e9bf.

📒 Files selected for processing (2)
  • frontend/src/App.jsx
  • frontend/src/components/shared/Backtotop.jsx

Comment thread frontend/src/components/shared/Backtotop.jsx Outdated
Comment thread frontend/src/components/shared/Backtotop.jsx
Comment thread frontend/src/components/shared/Backtotop.jsx

@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: 1

🤖 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/src/components/shared/Backtotop.jsx`:
- Around line 26-37: The conditional return of null at the start of the render
logic removes the button from the DOM entirely when invisible, preventing the
fade-in/fade-out animation from working. Keep the button mounted at all times
and instead conditionally apply opacity, transform (like translate), and
pointer-events classes based on the visible state. When visible is false, use
classes to fade out (opacity-0), move the element slightly (translate-y), and
disable interactions (pointer-events-none). Ensure the existing transition-all
and duration-300 classes remain active so the CSS changes smoothly animate.
Additionally, add aria-hidden="true" when the button is hidden to keep it
non-focusable for screen readers.
🪄 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

Run ID: afa024d7-c3d0-4372-8fd9-4eb24e19e9e3

📥 Commits

Reviewing files that changed from the base of the PR and between a79e9bf and 123f89f.

📒 Files selected for processing (1)
  • frontend/src/components/shared/Backtotop.jsx

Comment thread frontend/src/components/shared/Backtotop.jsx Outdated
Updated BackToTop component to improve visibility handling and accessibility attributes.
@Souradeep858

Copy link
Copy Markdown
Author

@kunalverma2512 Updated the BackToTop component to address all review comments:

  • Replaced react-icons with lucide-react to avoid the missing dependency issue.
  • Initialized visibility state on mount by calling toggleVisibility() inside useEffect.
  • Kept the button mounted to preserve the required fade-in/fade-out animation.
  • Prevented the hidden button from being keyboard-focusable using tabIndex={visible ? 0 : -1} and removed it from the accessibility tree with aria-hidden={!visible}.

This resolves the dependency, initial render, accessibility, and animation concerns raised in the review.

@kunalverma2512

Copy link
Copy Markdown
Owner

@Souradeep858 Not required

Some tips :
make sure you provide very good description and not like how you given in this PR which contains very bad presenation
Its not a way to present things

Use reasoning in PR description to explain issue more nicely

Thanks for noticing codelens

you can support this project by starring it

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Adding back to top button for better navigation

2 participants