diff --git a/apps/web/src/components/ui/combobox.tsx b/apps/web/src/components/ui/combobox.tsx index 739eb15b9a064..7db0b25dd5b81 100644 --- a/apps/web/src/components/ui/combobox.tsx +++ b/apps/web/src/components/ui/combobox.tsx @@ -106,7 +106,7 @@ function ComboboxInput({ function ComboboxSearchInput(props: React.ComponentProps) { return ( -
+
+ ); } diff --git a/apps/web/src/components/ui/menu.tsx b/apps/web/src/components/ui/menu.tsx index e2706d0da21bf..7c699733bb1a5 100644 --- a/apps/web/src/components/ui/menu.tsx +++ b/apps/web/src/components/ui/menu.tsx @@ -80,7 +80,7 @@ function MenuSearchInput({ ...props }: Omit & { busy?: boolean }) { return ( -
+
+ ); } diff --git a/apps/web/src/components/ui/search-input.browser.test.tsx b/apps/web/src/components/ui/search-input.browser.test.tsx new file mode 100644 index 0000000000000..a557c4ccf66af --- /dev/null +++ b/apps/web/src/components/ui/search-input.browser.test.tsx @@ -0,0 +1,37 @@ +import { expect, it } from "vite-plus/test"; +import { userEvent } from "vite-plus/test/browser"; + +import { render } from "../../../test/render"; +import { Combobox, ComboboxSearchInput } from "./combobox"; +import { MenuSearchInput } from "./menu"; + +it.each(["combobox", "menu"] as const)( + "focuses the %s search when clicking the right edge of its row", + async (kind) => { + await using screen = await render( +
+ {kind === "combobox" ? ( + + + + ) : ( + + )} +
, + { router: false /* input focus does not involve navigation */ }, + ); + const row = screen.getByTestId("search-row"); + const field = screen.getByRole(kind === "combobox" ? "combobox" : "textbox", { + name: "Search options", + }); + const { width, height } = row.element().getBoundingClientRect(); + + for (const x of [4, width / 2, width - 20, width - 4]) { + field.element().blur(); + await userEvent.click(row, { position: { x, y: height / 2 } }); + await expect.element(field).toHaveFocus(); + } + await userEvent.keyboard("project"); + await expect.element(field).toHaveValue("project"); + }, +);