Skip to content

Fix Page Scrolling Behavior After Closing Algolia Search Bar - #6957

Open
sreenath-here wants to merge 1 commit into
reactjs:mainfrom
sreenath-here:fix/page-scrolling-algolia-search
Open

Fix Page Scrolling Behavior After Closing Algolia Search Bar#6957
sreenath-here wants to merge 1 commit into
reactjs:mainfrom
sreenath-here:fix/page-scrolling-algolia-search

Conversation

@sreenath-here

@sreenath-here sreenath-here commented Jun 16, 2024

Copy link
Copy Markdown

Description:

This pull request addresses an issue where the website would scroll back to the top of the page after closing the Algolia search bar, regardless of the user's initial position on the page.

Issue:

Whenever the Algolia search bar is activated or clicked, and then subsequently closed, the page scrolls back to the top. This disrupts the user's experience, especially if they were in the middle of reading content further down the page.

Solution:

The following changes were made to resolve this issue:

  1. Implemented state management to store the user's scroll position before the search bar is activated.
  2. Ensured that the scroll position is restored when the search bar is closed.
  3. Added event listeners to manage scroll behavior effectively.

Changes:

  1. Added a state variable to store the scroll position.
  2. Modified the search bar activation and deactivation logic to handle scroll position.
  3. Updated relevant components to ensure seamless user experience.

Testing:

Tested on multiple pages to ensure the scroll position is correctly maintained after closing the search bar.
Verified that the fix does not introduce any new issues or regressions.

@vercel

vercel Bot commented Jun 16, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
19-react-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2024 3:49pm
react-dev ✅ Ready (Inspect) Visit Preview Jun 16, 2024 3:49pm

@github-actions

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 80.83 KB (🟡 +44 B) 184.98 KB
/500 80.83 KB (🟡 +44 B) 184.97 KB
/[[...markdownPath]] 82.68 KB (🟡 +44 B) 186.82 KB
/errors 81.04 KB (🟡 +44 B) 185.19 KB
/errors/[errorCode] 81.02 KB (🟡 +44 B) 185.16 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Comment thread src/content/blog/index.md
title: React Blog
author: React
date: 16-6-2024
description: "React official updates blog"

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.

Added these "author, date, description" as I am getting runtime error from rss feed.

@sreenath-here
sreenath-here marked this pull request as ready for review June 17, 2024 04:20
@sreenath-here

Copy link
Copy Markdown
Author

Screenshots:

Before:

Algolia.Before.mp4

After:

Algolia.after.mp4

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants