fix: prevent search viewport jump to top - #14
Open
ayanozoro wants to merge 1 commit into
Open
Conversation
MAY55A
requested changes
Jul 31, 2026
Owner
There was a problem hiding this comment.
@ayanozoro , thank you for your effort !
These are the remarks I made while reviewing your PR:
-
The viewport issue was indeed fixed for the elements in the changed files, but not all elements triggering the same issue were addressed, these are missing:
- project domain carousel
- project activity status filter
- pagination buttons
-
You can introduce the same fixes you used to these elements as well, to resolve this issue for all pages.
Would really appreciate it if you include any other elements with the same issue that we might have missed.
Author
|
ok i will resolve the issue in other pages also |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7
Description
Fixes an issue where submitting or typing in the search bar (as well as updating filter options and sorting) caused Next.js to scroll the viewport automatically to the top of the page (0,0), breaking the user flow.
Summary of Changes
Search Bar (src/components/custom/search-bar.tsx):
Wrapped search input in a <form onSubmit={(e) => e.preventDefault()}> to prevent full page reloads when pressing Enter.
Added { scroll: false } option to router.replace() during debounced search query updates.
Filters & Sorting Components:
Added { scroll: false } to router.replace() calls across related controls to keep the user anchored at their current scroll position:
src/components/discussions/sort-by-dropdown.tsx
src/components/discussions/categories-carousel.tsx
src/components/custom/tags-filter.tsx
src/components/projects/sort-by-dropdown.tsx
Acceptance Criteria Verified
Typing or submitting in the search bar no longer resets scroll position to the top of the page.
User remains smoothly anchored near the search bar and results container.
Related filter flows (category carousel, tag filters, sort dropdowns) function without scroll regressions.
Type of Change
Bug fix (non-breaking change fixing an issue)