Skip to content

Conversation

@Pratik5252
Copy link
Contributor

Fixes #949

Previous Behavior

When users clicked the X to clear the search input, the visual field was cleared but the search state in the parent component remained unchanged. This caused old search results to reappear when typing again.

Solution

Updated clearInput() to call onSearchChange("") so the parent component's search state is properly reset along with the input field.

Copilot AI review requested due to automatic review settings January 6, 2026 07:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #949 where the search cancel button only cleared the visual input field without resetting the parent component's search state, causing stale results to reappear.

Key Changes:

  • Added onSearchChange("") call in the clearInput() function to properly synchronize the parent component's search state when the clear button is clicked

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (inputRef.current) {
inputRef.current.value = "";
}
onSearchChange("")
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

Missing semicolon at the end of the statement. This file consistently uses semicolons throughout, as seen in lines 99, 105, and other statements in the codebase.

Suggested change
onSearchChange("")
onSearchChange("");

Copilot uses AI. Check for mistakes.
if (inputRef.current) {
inputRef.current.value = "";
}
onSearchChange("")
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

Consider adding a test for this bug fix to prevent regression. The test should verify that clicking the clear button resets both the input field and calls onSearchChange with an empty string. The repository has an established testing setup with vitest and testing-library (see test/components/CodeEmbed.test.tsx for reference), and this would be a good candidate for test coverage given it fixes a reported bug.

Copilot uses AI. Check for mistakes.
@Pratik5252 Pratik5252 closed this Jan 6, 2026
@Pratik5252 Pratik5252 deleted the fix-#949-search-cancel-button branch January 6, 2026 07:50
@Pratik5252 Pratik5252 restored the fix-#949-search-cancel-button branch January 6, 2026 07:58
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.

Search Cancel button does not delete query text

1 participant