Skip to content

feat: add keyboard event support to SearchBar#1425

Open
AasthathecoderX wants to merge 5 commits intolayer5io:masterfrom
AasthathecoderX:KeyboardEvents-clean
Open

feat: add keyboard event support to SearchBar#1425
AasthathecoderX wants to merge 5 commits intolayer5io:masterfrom
AasthathecoderX:KeyboardEvents-clean

Conversation

@AasthathecoderX
Copy link
Copy Markdown
Contributor

Notes for Reviewers

This PR fixes #718

Signed commits

  • Yes, I signed my commits.

@AasthathecoderX
Copy link
Copy Markdown
Contributor Author

The below are the videos showing the working::

enter_working.mp4
Tab_working.mp4
up_downworking.mp4
spacebar_working.mp4

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an onKeyDown prop to the SearchBar and StyledSearchBar components, enabling custom keyboard event handling and search execution via the 'Enter' key. Feedback focuses on enhancing the handleKeyDown logic to respect event.defaultPrevented, cleaning up redundant comments, and fixing indentation inconsistencies to maintain code quality.

Comment thread src/custom/SearchBar.tsx Outdated
Comment thread src/custom/SearchBar.tsx Outdated
Comment thread src/custom/StyledSearchBar/StyledSearchBar.tsx Outdated
Rajesh-Nagarajan-11 and others added 3 commits April 20, 2026 18:42
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Rajesh Nagarajan <139469505+Rajesh-Nagarajan-11@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Rajesh Nagarajan <139469505+Rajesh-Nagarajan-11@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: AasthathecoderX <bhat.aasthaa@gmail.com>
Copy link
Copy Markdown
Contributor

@miacycle miacycle left a comment

Choose a reason for hiding this comment

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

One thing worth tightening here: pressing Enter can trigger onSearch twice. handleSearchChange already schedules the debounced search, and if Enter is pressed before that debounce expires, handleKeyDown calls onSearch(searchText) immediately while the pending debounced call still fires shortly after. Please cancel the pending debounced callback before the immediate Enter-path search (or funnel Enter through the same search path) so consumers do not get duplicate requests or state updates.

@AasthathecoderX
Copy link
Copy Markdown
Contributor Author

One thing worth tightening here: pressing Enter can trigger onSearch twice. handleSearchChange already schedules the debounced search, and if Enter is pressed before that debounce expires, handleKeyDown calls onSearch(searchText) immediately while the pending debounced call still fires shortly after. Please cancel the pending debounced callback before the immediate Enter-path search (or funnel Enter through the same search path) so consumers do not get duplicate requests or state updates.

ok @miacycle ,I will look into it

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.

SearchBar does not support Keyboard Events

3 participants