Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: persist scroll position on page navigation #1778

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Naiduyenduva
Copy link

Issue: you will see bunch of videos when you open a purchased course, if you scroll to some video like 14th or 15 or to end and opens it and return back you will got to see the scroll position to 0. Again you need to scroll to open a neighbour video of previous one.

PR Fixes:

  • 1 Restored scroll position of purchased course videos tab
  • 2 open a video of a course comes back you will stay on the scroll position you are at

Resolves #[Issue Number if there]

Checklist before requesting a review

  • [* ] I have performed a self-review of my code
  • [* ] I assure there is no similar/duplicate pull request regarding same issue

@Naiduyenduva Naiduyenduva changed the title persist scroll position on page navigation feat: persist scroll position on page navigation Mar 8, 2025
@devsargam devsargam requested a review from Copilot March 9, 2025 09:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This pull request aims to persist the scroll position on page navigation in the purchased course videos tab so that users return to their previous position when navigating back from a video.

  • Restores the scroll position from sessionStorage on component mount.
  • Debounces scroll event updates and cleans up listeners on unmount.

Reviewed Changes

File Description
src/components/ContentCard.tsx Integrates scroll persistence logic via useEffect and sessionStorage.

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

@@ -37,6 +38,28 @@ export const ContentCard = ({
uploadDate?: string;
weeklyContentTitles?: string[];
}) => {
const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null);
Copy link
Preview

Copilot AI Mar 9, 2025

Choose a reason for hiding this comment

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

Embedding scroll persistence logic in the ContentCard component may lead to multiple event listeners being added if multiple cards are rendered on the page. Consider moving this logic to a higher-level component or creating a custom hook to handle scroll position management in a single place.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Author

Choose a reason for hiding this comment

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

done with the changes

@Naiduyenduva
Copy link
Author

Naiduyenduva commented Mar 10, 2025

@devsargam done with the changes sir ! if it's fine merge it and make as one commit

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.

1 participant