diff --git a/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx b/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx index d1852c4cec..3eecbf71f6 100644 --- a/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx +++ b/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx @@ -148,7 +148,9 @@ function Input({ onChange, handleAddNewEmail }: InputProps) { ) useEffect(() => { - if (suggestion && inputValue && !suggestion.startsWith(inputValue)) { + if (!inputValue) { + setSuggestion(null) + } else if (suggestion && !suggestion.startsWith(inputValue)) { setSuggestion(null) } }, [suggestion, inputValue]) diff --git a/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx b/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx index c9f1ec18df..491a940c6c 100644 --- a/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx +++ b/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx @@ -146,11 +146,11 @@ describe('', function () { ).to.equal(true) }) - it('should clear the suggestion when the potential domain match is completely deleted', function () { + it('should clear the suggestion when the potential domain match is completely deleted', async function () { + await screen.findByText('user@domain.edu') fireEvent.change(screen.getByRole('textbox'), { - target: { value: 'user@' }, + target: { value: '' }, }) - expect(onChangeStub.calledWith('user@')).to.equal(true) expect(screen.queryByText('user@domain.edu')).to.be.null })