Skip to content

fix: clear stale search query on manual input reset#202

Merged
AmintaCCCP merged 1 commit into
mainfrom
fix/search-clear-sort-reset
Jun 6, 2026
Merged

fix: clear stale search query on manual input reset#202
AmintaCCCP merged 1 commit into
mainfrom
fix/search-clear-sort-reset

Conversation

@AmintaCCCP

@AmintaCCCP AmintaCCCP commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Clear the committed repository search query when the search input is manually emptied
  • Add SearchBar regression coverage for manual clear followed by sort direction toggling
  • Keep existing sort/filter store merge behavior unchanged

Fixes #195

Testing

  • ✅ npm run test:run -- src/components/SearchBar.test.tsx
  • ✅ npm run build
  • ⚠️ npm run test:run currently fails in existing MarkdownRenderer line-number coverage unrelated to this change
  • ⚠️ npm run lint currently fails on existing project lint errors unrelated to this change

Notes

  • Untracked local files .claude/hook-log.txt and star-growth-chart.html were not included in this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed search input clearing behavior. Previously, clearing the search input field would not properly reset the search query state. The search now correctly clears when the input becomes empty, preventing stale query information from persisting and affecting subsequent filtering and sorting operations.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f6a9458d-6c8f-47fc-b9cb-14c3760a7c69

📥 Commits

Reviewing files that changed from the base of the PR and between dcdc1c7 and 91013bc.

📒 Files selected for processing (2)
  • src/components/SearchBar.test.tsx
  • src/components/SearchBar.tsx

📝 Walkthrough

Walkthrough

This PR fixes a bug where cleared search input did not reset the committed query state. SearchBar's input handler now detects when the input becomes empty and clears the query field in searchFilters. A comprehensive test suite with mocked store and localStorage verifies the clearing behavior and interaction with sort order changes.

Changes

Search Query Clearing on Empty Input

Layer / File(s) Summary
SearchBar query clearing logic
src/components/SearchBar.tsx
handleInputChange detects when input trims to empty while searchFilters.query is non-empty, and resets query to an empty string before proceeding with real-time search and suggestion UI logic.
SearchBar test suite with mocks and cases
src/components/SearchBar.test.tsx
Vitest useAppStore and localStorage mocks are configured; test helpers build consistent store state; two test cases verify that manual input clearing calls setSearchFilters with { query: '' }, and that subsequent sort order updates preserve the cleared query while updating sortOrder.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 The search bar now clears its mind,
When input becomes undefined,
No stale queries left behind,
Sort and filter, aligned!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: clearing stale search query when the search input is manually reset.
Linked Issues check ✅ Passed The PR directly addresses issue #195 by clearing committed search query when input is emptied, preventing stale queries from persisting with subsequent actions like sorting.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the stale search query issue: SearchBar.tsx input handler clears query on empty input, and SearchBar.test.tsx adds regression tests for this behavior and sorting interaction.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/search-clear-sort-reset

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AmintaCCCP AmintaCCCP merged commit 82b22d4 into main Jun 6, 2026
5 checks passed
@AmintaCCCP AmintaCCCP deleted the fix/search-clear-sort-reset branch June 6, 2026 14:12
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.

搜索问题

1 participant