Fixing flaky domain search test.

This commit is contained in:
Roland 2026-05-31 13:09:20 -06:00
parent 345b69b7d7
commit 5497e1eb61
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 13 additions and 8 deletions

View file

@ -435,14 +435,14 @@ const useClearableInput = (searchStr, onChange, onClear, onSubmit, size = 'small
const [submitted, setSubmitted] = useState(false);
React.useEffect(() => {
// Search was changed above.
if (searchStr !== value) {
setValue(searchStr);
// `searchStr` is the source of truth from the parent (often an async URL query param).
// Depend ONLY on `searchStr` -- never on `value` -- otherwise a transient render where the
// local `value` has advanced (e.g. "ex") but `searchStr` still trails ("e") fires this
// effect and reverts `value`, garbling fast typing (flaky filter test).
if ((searchStr || '') !== value) {
setValue(searchStr || '');
}
if (!searchStr) {
setValue('');
}
}, [searchStr, value]);
}, [searchStr]);
const handleChange = (e) => {
if (e) {