Skip to content

fix: sync SearchBar input with updated defaultValue prop#65057

Open
bhumikasudarshani-cmd wants to merge 1 commit intoapache:mainfrom
bhumikasudarshani-cmd:fix/searchbar-defaultvalue-sync
Open

fix: sync SearchBar input with updated defaultValue prop#65057
bhumikasudarshani-cmd wants to merge 1 commit intoapache:mainfrom
bhumikasudarshani-cmd:fix/searchbar-defaultvalue-sync

Conversation

@bhumikasudarshani-cmd
Copy link
Copy Markdown

@bhumikasudarshani-cmd bhumikasudarshani-cmd commented Apr 11, 2026

Problem

The SearchBar component initializes its internal state using the defaultValue prop, but does not stay in sync when defaultValue changes after the initial render.

This commonly happens when the search value is controlled via URL query parameters (e.g., in pages like DagsList, Connections, AssetsList). When navigation actions (such as back/forward) update the query params, the defaultValue prop changes, but the input field does not reflect the updated value.

Current behavior:

  • The actual filter (URL/query param) updates
  • The SearchBar input does NOT update
  • UI and filter state become inconsistent

Expected behavior:

  • SearchBar input should update whenever defaultValue changes
  • UI should always reflect the current filter state
  • No mismatch between visible input and actual filter

Fix

Added useEffect to watch defaultValue and sync internal state:

useEffect(() => {
  setValue(defaultValue);
}, [defaultValue]);

Also added useEffect to the import statement.

Testing

  • Added new test: Updates input when defaultValue prop changes
  • All 2 SearchBar tests pass
  • All 148 UI tests pass

Affected Pages

Any page using SearchBar with URL-driven filters:

  • DagsList
  • Connections
  • AssetsList

Closes #65053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SearchBar does not sync with updated defaultValue (URL-driven filters)

1 participant