Merge pull request #11002 from overleaf/msm-fix-email-suggestion
[web] Fix clearing suggestions in email input GitOrigin-RevId: c821114e2112bf066f4ee5f01304321db983bc4e
This commit is contained in:
@@ -148,7 +148,9 @@ function Input({ onChange, handleAddNewEmail }: InputProps) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (suggestion && inputValue && !suggestion.startsWith(inputValue)) {
|
if (!inputValue) {
|
||||||
|
setSuggestion(null)
|
||||||
|
} else if (suggestion && !suggestion.startsWith(inputValue)) {
|
||||||
setSuggestion(null)
|
setSuggestion(null)
|
||||||
}
|
}
|
||||||
}, [suggestion, inputValue])
|
}, [suggestion, inputValue])
|
||||||
|
|||||||
+3
-3
@@ -146,11 +146,11 @@ describe('<AddEmailInput/>', function () {
|
|||||||
).to.equal(true)
|
).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'), {
|
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
|
expect(screen.queryByText('user@domain.edu')).to.be.null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user