-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves the MultiEmailIput component interactions. (#2359)
* Set the value of the props menuIsOpen from the local state and the local state will be set to true only when the input has some content. * Cleaned up the paste event handler to gracefully handle the email creation based on the pasted content. * Sets the isMenuOpen to false once an email change is handled. * Added test case to verify the functionality.
- Loading branch information
1 parent
bf1f004
commit eb90348
Showing
3 changed files
with
47 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,4 +290,26 @@ describe("MultiEmailInput", () => { | |
{ label: "[email protected]", valid: true, value: "[email protected]" }, | ||
]); | ||
}); | ||
|
||
it("should not render the menu when clicked on the input field", async () => { | ||
const onChange = jest.fn(); | ||
const selectedEmails = SAMPLE_EMAILS.slice(0, 2); | ||
const { container } = render( | ||
<MultiEmailInput | ||
{...{ onChange }} | ||
options={SAMPLE_EMAILS} | ||
value={selectedEmails} | ||
/> | ||
); | ||
const emailInput = screen.getByRole("combobox"); | ||
await userEvent.click(emailInput); | ||
expect( | ||
container.querySelector(".neeto-ui-react-select__menu") | ||
).not.toBeInTheDocument(); | ||
|
||
await userEvent.type(emailInput, "test"); | ||
await expect( | ||
container.querySelector(".neeto-ui-react-select__menu") | ||
).toBeInTheDocument(); | ||
}); | ||
}); |