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

Refactor the SearchBox component to manage input reset with local state #439

Open
nozomione opened this issue Jan 9, 2025 · 0 comments
Open
Assignees

Comments

@nozomione
Copy link
Member

Context

The current implementation of the shared SearchBox component relies on parent components to manage the search input field value via the onChange prop. This also includes the responsibility of clearing the input (i.e., resetting it to an empty string).

SearchBox is shared across the following components:

  • pages/search/index
  • Compendia/DownloadBlock
  • Home/HeroBody
  • SearchResults/SearchFilter

In this PR, we'll shift the responsibility of resetting the input value to SearchBox itself by using local state. This change will simplify the state management of the input value within SearchBox and reduce the dependency on parent components.

Additionally, any event handler props passed from the parent (e.g., onChange, onSubmit) will be converted to no-op functions by default unless explicitly needed.

Solution or next step

  • Add a new local state to SearchBox for managing the input rest
  • Set all event handler props to noop by default
  • Update the parent components accordingly
@nozomione nozomione self-assigned this Jan 9, 2025
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

No branches or pull requests

1 participant