mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 05:39:57 -05:00
Fixing flaky domain search test.
This commit is contained in:
parent
345b69b7d7
commit
5497e1eb61
2 changed files with 13 additions and 8 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue