Skip to content

feat: add floating Scroll-to-Top button for improved navigation#513

Merged
ritesh-1918 merged 19 commits into
ritesh-1918:gssocfrom
unsiqasik:feat/scroll-to-top-button
May 29, 2026
Merged

feat: add floating Scroll-to-Top button for improved navigation#513
ritesh-1918 merged 19 commits into
ritesh-1918:gssocfrom
unsiqasik:feat/scroll-to-top-button

Conversation

@unsiqasik
Copy link
Copy Markdown

@unsiqasik unsiqasik commented May 28, 2026

Summary

Adds a floating Scroll-to-Top button that enhances navigation on long pages.

Changes

  • New Component: ScrollToTopButton in Frontend/src/components/shared/
    • Appears after scrolling down 300px with smooth fade-in animation
    • Disappears when near the top with fade-out animation
    • Smooth scroll animation back to top on click
    • Responsive fixed positioning (bottom-right corner)
    • Accessible with aria-label and title attributes
    • Uses Tailwind CSS for styling with hover and focus states
    • Blue circular button with arrow-up icon

Implementation Details

  • Uses useState and useEffect for scroll position tracking
  • CSS transitions for smooth visibility changes
  • pointer-events-none when hidden to prevent accidental clicks
  • Focus ring for keyboard accessibility
  • Added to both main app and docs subdomain layouts

Testing

  • Button appears after scrolling down
  • Button smoothly scrolls to top when clicked
  • Button fades in/out correctly
  • Responsive on mobile and desktop
  • Keyboard accessible

Closes #250

Summary by CodeRabbit

  • New Features
    • Added a floating "Scroll to Top" button that appears when you scroll down the page. Click it to smoothly return to the top with an animated scroll effect. Available throughout the application and documentation.

Review Change Stack

namann5 and others added 19 commits May 22, 2026 11:30
- Replace raw user_id with SHA256 hash (8-char prefix) in all log statements
- Maintains audit trail capability while protecting user identifiers (PII)
- Complies with GDPR/CCPA privacy requirements
- Hash is deterministic for correlation without exposing PII

Resolves CodeRabbit PII logging concern
…backfill

Fix tenant ticket orphaning by persisting company_id on save
…ashboard

feat: Real-time Support Dashboard Updates Using Supabase Realtime Channels
- Add ScrollToTopButton component with fade-in/fade-out animation
- Button appears after scrolling down 300px
- Smooth scroll animation back to top
- Responsive positioning (bottom-right corner)
- Accessible with aria-label and title attributes
- Uses Tailwind CSS for styling with hover/focus states

Closes ritesh-1918#250
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

@zeroknowledge0x is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

This PR adds a scroll-to-top button feature to the application. A new ScrollToTopButton component monitors scroll position and displays a floating button when the user scrolls past 300 pixels, providing smooth scrolling back to the top on click. The component is integrated into the main app layout for both documentation and standard subdomains.

Changes

Scroll to Top Button Feature

Layer / File(s) Summary
ScrollToTopButton component
Frontend/src/components/shared/ScrollToTopButton.jsx
New React component with scroll event listener that shows a fixed floating button when window.scrollY > 300, performs smooth scroll-to-top on click, and includes accessibility attributes (aria-label, title).
App layout integration
Frontend/src/App.jsx
Imports ScrollToTopButton and renders it in both the docs subdomain and main application BrowserRouter branches, positioned immediately after the existing ScrollToTop component.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

A button appears, floating up high,
When scrollers descend through sections so wide,
One click brings them back to the sky—
No more weary thumbs on the ride! 🐰⬆️

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a floating Scroll-to-Top button component for improved navigation, which matches the core objective.
Linked Issues check ✅ Passed The implementation fulfills all coding requirements from issue #250: component appears after 300px scroll, smooth scroll animation, responsive positioning, fade-in/out transitions, accessibility features (aria-label, title, focus ring), and Tailwind CSS styling.
Out of Scope Changes check ✅ Passed All changes are within scope: the new ScrollToTopButton component and its integration into App.jsx are directly aligned with issue #250 requirements; no extraneous modifications detected.

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

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/ScrollToTopButton.jsx`:
- Around line 12-19: The effect that registers toggleVisibility only updates
visibility on scroll, so the button may remain hidden if the page mounts at a
deep scroll position; inside the useEffect that defines toggleVisibility (the
effect that adds/removes the "scroll" listener), call toggleVisibility() once
immediately after adding the listener (or before) to initialize isVisible via
setIsVisible, ensuring the ScrollToTopButton reflects the current window.scrollY
on mount; keep the existing cleanup that removes the listener.
- Around line 30-39: The button remains in the keyboard tab order when hidden;
update the button element that uses isVisible (the one with
onClick={scrollToTop}) to remove it from the accessibility tree and from tab
order when isVisible is false by setting tabIndex={isVisible ? 0 : -1} and
aria-hidden={isVisible ? "false" : "true"} (or aria-hidden={!isVisible}) so it
is non-focusable and hidden from AT while visually hidden.
🪄 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: 0e09eefe-a6e7-4dbb-9b36-f9d2226e71f3

📥 Commits

Reviewing files that changed from the base of the PR and between fb6a950 and 4ff8b23.

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

Comment on lines +12 to +19
useEffect(() => {
const toggleVisibility = () => {
setIsVisible(window.scrollY > 300);
};

window.addEventListener("scroll", toggleVisibility);
return () => window.removeEventListener("scroll", toggleVisibility);
}, []);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Initialize visibility once on mount.

At Line 12, isVisible only updates after a scroll event. If the page restores at a deep scroll position, the button stays incorrectly hidden until the user scrolls again. Call toggleVisibility() once inside the effect.

Suggested fix
   useEffect(() => {
     const toggleVisibility = () => {
       setIsVisible(window.scrollY > 300);
     };

+    toggleVisibility();
     window.addEventListener("scroll", toggleVisibility);
     return () => window.removeEventListener("scroll", toggleVisibility);
   }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
const toggleVisibility = () => {
setIsVisible(window.scrollY > 300);
};
window.addEventListener("scroll", toggleVisibility);
return () => window.removeEventListener("scroll", toggleVisibility);
}, []);
useEffect(() => {
const toggleVisibility = () => {
setIsVisible(window.scrollY > 300);
};
toggleVisibility();
window.addEventListener("scroll", toggleVisibility);
return () => window.removeEventListener("scroll", toggleVisibility);
}, []);
🤖 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/src/components/shared/ScrollToTopButton.jsx` around lines 12 - 19,
The effect that registers toggleVisibility only updates visibility on scroll, so
the button may remain hidden if the page mounts at a deep scroll position;
inside the useEffect that defines toggleVisibility (the effect that adds/removes
the "scroll" listener), call toggleVisibility() once immediately after adding
the listener (or before) to initialize isVisible via setIsVisible, ensuring the
ScrollToTopButton reflects the current window.scrollY on mount; keep the
existing cleanup that removes the listener.

Comment on lines +30 to +39
<button
onClick={scrollToTop}
className={`fixed bottom-6 right-6 z-50 flex h-12 w-12 items-center justify-center rounded-full bg-blue-600 text-white shadow-lg transition-all duration-300 hover:bg-blue-700 hover:shadow-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${
isVisible
? "translate-y-0 opacity-100"
: "pointer-events-none translate-y-4 opacity-0"
}`}
aria-label="Scroll to top"
title="Scroll to top"
>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Hidden button is still keyboard-focusable.

At Line 30, the button stays in the tab order even when visually hidden (opacity-0). This creates an invisible focus target for keyboard/screen-reader users. Make it non-focusable/hidden from AT when isVisible is false.

Suggested fix
     <button
       onClick={scrollToTop}
+      tabIndex={isVisible ? 0 : -1}
+      aria-hidden={!isVisible}
       className={`fixed bottom-6 right-6 z-50 flex h-12 w-12 items-center justify-center rounded-full bg-blue-600 text-white shadow-lg transition-all duration-300 hover:bg-blue-700 hover:shadow-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${
         isVisible
           ? "translate-y-0 opacity-100"
           : "pointer-events-none translate-y-4 opacity-0"
       }`}
🤖 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/src/components/shared/ScrollToTopButton.jsx` around lines 30 - 39,
The button remains in the keyboard tab order when hidden; update the button
element that uses isVisible (the one with onClick={scrollToTop}) to remove it
from the accessibility tree and from tab order when isVisible is false by
setting tabIndex={isVisible ? 0 : -1} and aria-hidden={isVisible ? "false" :
"true"} (or aria-hidden={!isVisible}) so it is non-focusable and hidden from AT
while visually hidden.

@ritesh-1918 ritesh-1918 changed the base branch from main to gssoc May 29, 2026 19:27
@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented May 29, 2026

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
29368972 Triggered Supabase Service Role JWT b460068 scratch/test_companies.js View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@ritesh-1918 ritesh-1918 added gssoc GirlScript Summer of Code gssoc:approved GSSoC Approved PR level:critical Critical level difficulty quality:exceptional Exceptional code quality type:feature New feature labels May 29, 2026
@ritesh-1918
Copy link
Copy Markdown
Owner

Hi @unsiqasik! Thanks for the contribution. I have successfully converted your PR's target branch to gssoc to keep our codebase unified.

PR approved and merged! Welcome to the family! 🚀💻


🌟 Developer Action Network

Before starting or submitting updates, please complete these quick onboarding steps:

  1. Star this repository: https://github.com/ritesh-1918/HELPDESK.AI
  2. 👤 Follow the Project Admin: https://github.com/ritesh-1918
  3. 💼 Connect on LinkedIn: https://www.linkedin.com/in/ritesh1908/

Note: All PR branches must target the gssoc branch, NOT main.

@ritesh-1918 ritesh-1918 merged commit 7c53018 into ritesh-1918:gssoc May 29, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC Approved PR gssoc GirlScript Summer of Code level:critical Critical level difficulty quality:exceptional Exceptional code quality type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add Scroll-to-Top Button for Improved User Navigation

5 participants