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

fix(clear-search): Fixed Clear Search When Someone Clicks Out of The Page. #18

Merged
merged 6 commits into from
Jan 28, 2024

Conversation

MirzaHanan
Copy link
Contributor

Problem:

The application retains the search term in the UI state when users navigate away from the profile page to either the people page or the bounty homepage and other routes. This behavior is inconsistent with typical user expectations where a search term should be cleared upon navigating to a different page.

Expected Behavior:

When a user navigates away from the profile page, the search term entered should be automatically cleared. This ensures that when the user visits the people page or the bounty homepage and other all routes, they are presented with a fresh state, unfiltered by their previous search.

Issue ticket number and link:

Solution:

The solution involves adding an event listener in the UiStore class constructor to detect click events on the document. If a click event occurs outside the search input (.search-input-wrapper), the clearSearchText method is called to reset the searchText state to an empty string.

Changes:

  • Modified the UiStore class constructor to include a document click event listener.
  • Implemented handleDocumentClick, a method to check the target of click events and determine if they occur outside the search input area.
  • Developed clearSearchText method to reset the search text.

Evidence:

Please see the attached video as evidence.

Testing:

  • Click-based Navigation: Clicking on various elements and navigating to different pages to verify that the search term is cleared.
  • Keyboard Navigation: Ensuring that non-click based navigations also result in the search term being cleared.
  • Edge Cases: Testing with rapid navigation, back and forth between pages, and refreshing pages to observe the persistence of the search term.

@MirzaHanan
Copy link
Contributor Author

Hi @ecurrencyhodler,
Please review this PR

@ecurrencyhodler
Copy link
Contributor

Okay let's get a code review. GJ.

@elraphty
Copy link
Collaborator

@MirzaHanan This breaks the search on the People Tab
Search

@MirzaHanan
Copy link
Contributor Author

Hi @elraphty,
Please check the search functionality in demo on the People Tab; it is already broken.

@ecurrencyhodler
Copy link
Contributor

We just merged a fix. Can you pull from master again? Also you have a read.me conflicting file.

@MirzaHanan
Copy link
Contributor Author

Ok @ecurrencyhodler

@MirzaHanan MirzaHanan force-pushed the clear-search-back-page branch from 4cf5f3c to 3c2fbdf Compare January 25, 2024 22:39
@MirzaHanan
Copy link
Contributor Author

@ecurrencyhodler Please check it.

@ecurrencyhodler
Copy link
Contributor

Great job! Okay we need a code review.

@elraphty elraphty merged commit 6342d70 into stakwork:master Jan 28, 2024
4 checks passed
@ecurrencyhodler
Copy link
Contributor

Tested and paid. LGTM!

@ecurrencyhodler
Copy link
Contributor

Actually mirza there was one scenario where this wasn't addressed. I recorded it here. It looks like when I search inside a profile and go to people's page, the search is saved but hidden.

Can you do a follow up PR so that the search is completely cleared?

Screen.Recording.2024-01-28.at.8.51.32.PM.mov

@MirzaHanan
Copy link
Contributor Author

Hi @ecurrencyhodler,
I fix it today.

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.

4 participants