diff --git a/app/cypress/e2e/domains/domains-list.cy.js b/app/cypress/e2e/domains/domains-list.cy.js index 2ebdd92a..1f4be916 100644 --- a/app/cypress/e2e/domains/domains-list.cy.js +++ b/app/cypress/e2e/domains/domains-list.cy.js @@ -124,7 +124,12 @@ describe('Domains List Page', () => { }); it('filters domains with search', () => { - cy.get('input[placeholder="Domain filter..."]').type('example'); + cy.get('input[placeholder="Domain filter..."]') + .type('example') + // Confirm the input itself stabilized before asserting downstream effects. + .should('have.value', 'example'); + // The filter is driven by the URL query param; wait for the router to commit it. + cy.url().should('include', 'domain=example'); // Chain assertions so they retry together with the extended timeout cy.get('table:visible tbody tr', {timeout: 10000}) .should('have.length', 1) diff --git a/app/src/components/Common.js b/app/src/components/Common.js index 22aebb60..f2d7f78b 100644 --- a/app/src/components/Common.js +++ b/app/src/components/Common.js @@ -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) {