Tooltip: close field tooltip when ESC is pressed (#12553)

* Close field tooltip when ESC is pressed

* Use `Key.ESCAPE`
This commit is contained in:
Florian Duros 2024-05-28 14:55:47 +02:00 committed by GitHub
parent e8bb2419c9
commit 17ab522942
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 2 deletions

View file

@ -69,6 +69,10 @@ describe("Field", () => {
// Expect 'alert' role
expect(screen.queryByRole("alert")).toBeInTheDocument();
// Close the feedback is Escape is pressed
fireEvent.keyDown(screen.getByRole("textbox"), { key: "Escape" });
expect(screen.queryByRole("alert")).toBeNull();
});
it("Should mark the feedback as status if valid", async () => {
@ -87,6 +91,10 @@ describe("Field", () => {
// Expect 'status' role
expect(screen.queryByRole("status")).toBeInTheDocument();
// Close the feedback is Escape is pressed
fireEvent.keyDown(screen.getByRole("textbox"), { key: "Escape" });
expect(screen.queryByRole("status")).toBeNull();
});
it("Should mark the feedback as tooltip if custom tooltip set", async () => {
@ -106,6 +114,10 @@ describe("Field", () => {
// Expect 'tooltip' role
expect(screen.queryByRole("tooltip")).toBeInTheDocument();
// Close the feedback is Escape is pressed
fireEvent.keyDown(screen.getByRole("textbox"), { key: "Escape" });
expect(screen.queryByRole("tooltip")).toBeNull();
});
});
});