Skip to content

fix: clear input function in Repository searchbox#1283

Merged
e35ventura merged 1 commit into
entrius:testfrom
bittoby:fix/repositories-search-clear-button
May 28, 2026
Merged

fix: clear input function in Repository searchbox#1283
e35ventura merged 1 commit into
entrius:testfrom
bittoby:fix/repositories-search-clear-button

Conversation

@bittoby
Copy link
Copy Markdown
Contributor

@bittoby bittoby commented May 27, 2026

Summary

Fixes the X (clear) button in the search input on /repositories. Previously, clicking X would clear the field for a single frame and then the previous search term reappeared, with ?search=… immediately restored in the URL. The button is now a real no-op-free clear: input empties, URL param is removed, full list shows.

Root cause was a callback-identity cascade in DebouncedSearchInput:

  • React Router 6's setSearchParams is rebuilt on every URL change, so any callback derived from it (setFilterhandleSearchChange → the onDebouncedChange prop) gets a new reference per URL update.
  • DebouncedSearchInput's fire-effect had onDebouncedChange in its dep array, so it re-ran with the stale debounced value the moment the URL changed — re-applying the old search term right after the clear.

Fix uses the latest-ref pattern in src/components/common/DebouncedSearchInput.tsx: the fire-effect now depends only on debounced, while the callback is read from a ref kept in sync via a separate effect. This fixes the bug at the source and protects every other caller (IssuesList, RepositoryPRsTable, RepositoryCodeBrowser, LanguageWeightsTable, MinerPRsTable, MinerOpenDiscoveryIssuesByRepo, WatchlistPage) from the same trap.

Related Issues

Fixes #1282

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Screenshots

Before — clicking X briefly clears the input, then git reappears and ?search=git is restored:

before.webm

After — clicking X clears the input and removes ?search= from the URL:

after.webm

Checklist

  • New components are modularized/separated where sensible
  • Uses predefined theme (e.g. no hardcoded colors)
  • Responsive/mobile checked
  • Tested against the test API
  • npm run format and npm run lint:fix have been run
  • npm run build passes
  • Screenshots included for any UI/visual changes

@e35ventura e35ventura merged commit cdd4181 into entrius:test May 28, 2026
2 checks passed
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.

[Bug] Clear (X) button on Repositories search does not clear the input - value reappears immediately

2 participants