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 debouncing cleanup issue in styled search bar #764

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

amitamrutiya
Copy link
Contributor

This pull request includes several changes to the StyledSearchBar component in src/custom/StyledSearchBar/StyledSearchBar.tsx to improve its functionality and usability. The most important changes include replacing useCallback with useEffect for handling debounced input changes, adding a debounceTime prop, and ensuring the input value is synchronized with the value prop.

Enhancements to StyledSearchBar component:

  • Replaced useCallback with useEffect to handle debounced input changes, ensuring the debounce logic is more efficient and easier to manage. (src/custom/StyledSearchBar/StyledSearchBar.tsx, src/custom/StyledSearchBar/StyledSearchBar.tsxL3-R3)
  • Added a new debounceTime prop to SearchBarProps to allow customization of the debounce duration for the input change handler. (src/custom/StyledSearchBar/StyledSearchBar.tsx, [1] [2]
  • Updated the StyledSearchBar component to initialize inputValue with an empty string if value is undefined, ensuring consistent behavior. (src/custom/StyledSearchBar/StyledSearchBar.tsx, src/custom/StyledSearchBar/StyledSearchBar.tsxL38-L56)
  • Added an effect to synchronize inputValue with the value prop, ensuring the component reflects external changes to the value prop. (src/custom/StyledSearchBar/StyledSearchBar.tsx, src/custom/StyledSearchBar/StyledSearchBar.tsxL38-L56)

Signed-off-by: Amit Amrutiya <[email protected]>
@amitamrutiya amitamrutiya merged commit 680a777 into layer5io:master Oct 18, 2024
8 checks passed
@amitamrutiya amitamrutiya deleted the fix-debouncing branch October 18, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant