Skip to content

fix: prevent search viewport jump to top - #14

Open
ayanozoro wants to merge 1 commit into
MAY55A:devfrom
ayanozoro:main
Open

fix: prevent search viewport jump to top#14
ayanozoro wants to merge 1 commit into
MAY55A:devfrom
ayanozoro:main

Conversation

@ayanozoro

Copy link
Copy Markdown

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)

@MAY55A MAY55A left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@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.

@ayanozoro

Copy link
Copy Markdown
Author

ok i will resolve the issue in other pages also

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.

[Bug]: Search causes page to jump to top instead of staying anchored at search bar/results

2 participants