A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix(applications): stop list rows from capturing clicks across the page in Safari (#3671)
albanofazzito5d247c59de92
diff --git a/apps/web/src/features/applications/components/list-view.test.tsx b/apps/web/src/features/applications/components/list-view.test.tsxindex dc05509b9..3d3aeb5c7 100644--- a/apps/web/src/features/applications/components/list-view.test.tsx+++ b/apps/web/src/features/applications/components/list-view.test.tsx@@ -1,6 +1,7 @@import type { Application } from "../types";// @vitest-environment happy-domimport { fireEvent, render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";import { expect, it, vi } from "vite-plus/test";import { i18n } from "@lingui/core";import { I18nProvider } from "@lingui/react";@@ -17,6 +18,7 @@ vi.mock("@/libs/orpc/client", () => ({},}));vi.mock("../use-application-actions", () => ({ useInvalidateApplications: () => mocks.invalidate }));+vi.mock("@/hooks/use-confirm", () => ({ useConfirm: () => vi.fn() }));vi.mock("@reactive-resume/ui/hooks/use-breakpoint", () => ({ useBreakpoint: () => mocks.breakpoint }));const LONG_NOTE =@@ -42,14 +44,14 @@ const application = (over: Partial<Application> = {}): Application =>...over,}) as Application;-function renderList(applications: Application[], breakpoint = "desktop") {+function renderList(applications: Application[], breakpoint = "desktop", onOpen = vi.fn()) {mocks.breakpoint = breakpoint;i18n.load("en", {});i18n.activate("en");return render(<QueryClientProvider client={new QueryClient()}><I18nProvider i18n={i18n}>- <ApplicationList applications={applications} showClosed selectedId={null} onOpen={() => {}} />+ <ApplicationList applications={applications} showClosed selectedId={null} onOpen={onOpen} /></I18nProvider></QueryClientProvider>,);@@ -96,6 +98,58 @@ it("keeps automatic layout and single-cell rows on phones", () => {expect(screen.getByText(`Globex · ${LONG_NOTE}`)).toBeTruthy();});+const twoApplications = () => [+ application(),+ application({ id: "app-2", role: "Product Designer", company: "Initech", location: "Austin" }),+];++it.each(["desktop", "mobile"] as const)("opens the clicked row's application on %s", (breakpoint) => {+ const onOpen = vi.fn();+ renderList(twoApplications(), breakpoint, onOpen);++ fireEvent.click(screen.getByText("Product Designer").closest("tr") as HTMLElement);++ expect(onOpen).toHaveBeenCalledOnce();+ expect(onOpen).toHaveBeenCalledWith(expect.objectContaining({ id: "app-2" }));+});++it.each(["desktop", "mobile"] as const)("opens once from the role button on %s", async (breakpoint) => {+ const onOpen = vi.fn();+ renderList(twoApplications(), breakpoint, onOpen);+ const user = userEvent.setup();+ const button = screen.getByRole("button", { name: /Product Designer/ });++ await user.click(button);+ expect(onOpen).toHaveBeenCalledOnce();+ onOpen.mockClear();+ await user.keyboard("{Enter}");+ expect(onOpen).toHaveBeenCalledOnce();+ onOpen.mockClear();+ await user.keyboard(" ");+ expect(onOpen).toHaveBeenCalledOnce();+ expect(onOpen).toHaveBeenCalledWith(expect.objectContaining({ id: "app-2" }));+});++it("selects a row without opening it", () => {+ const onOpen = vi.fn();+ renderList(twoApplications(), "desktop", onOpen);++ const checkbox = screen.getByRole("checkbox", { name: "Select Product Designer at Initech" });+ fireEvent.click(checkbox);+ fireEvent.click(checkbox.closest("td") as HTMLElement);++ expect(onOpen).not.toHaveBeenCalled();+ expect(checkbox.getAttribute("aria-checked")).toBe("true");+});++it.each(["desktop", "mobile"] as const)(+ "does not stretch a click target over the page on %s, since Safari ignores position on table rows",+ (breakpoint) => {+ const { container } = renderList(twoApplications(), breakpoint);++ expect(container.querySelector("[class*='after:absolute']")).toBeNull();+ },+);it("sorts by role with company as the tiebreak, and by soonest next step with none last", () => {const { container } = renderList([application({ id: "a", role: "Designer", company: "Zeta", location: null }),diff --git a/apps/web/src/features/applications/components/list-view.tsx b/apps/web/src/features/applications/components/list-view.tsxindex 4f0af0e1d..80e15a77d 100644--- a/apps/web/src/features/applications/components/list-view.tsx+++ b/apps/web/src/features/applications/components/list-view.tsx@@ -260,11 +260,7 @@ const ApplicationRow = memo(function ApplicationRow({);const openButton = (- <button- type="button"- onClick={() => onOpen(application)}- className="grid min-w-0 text-start after:absolute after:inset-0"- >+ <button type="button" className="grid min-w-0 cursor-pointer text-start"><span className="truncate font-medium">{application.role}</span><span className="truncate text-xs text-ink-3">{phone@@ -276,7 +272,10 @@ const ApplicationRow = memo(function ApplicationRow({if (phone) {return (- <tr className={cn("relative border-b border-line", selected && "bg-accent-soft/50")}>+ <tr+ onClick={() => onOpen(application)}+ className={cn("cursor-pointer border-b border-line", selected && "bg-accent-soft/50")}+ ><td className="py-2.5 ps-1"><div className="flex items-center gap-3">{initial}@@ -290,12 +289,13 @@ const ApplicationRow = memo(function ApplicationRow({return (<tr+ onClick={() => onOpen(application)}className={cn(- "relative border-b border-line transition-colors duration-quick hover:bg-hover",+ "cursor-pointer border-b border-line transition-colors duration-quick hover:bg-hover",selected && "bg-accent-soft/50",)}>- <td className="relative z-10 w-10 ps-3">+ <td onClick={(event) => event.stopPropagation()} className="w-10 cursor-default ps-3"><Checkboxchecked={checked}onCheckedChange={() => onCheck(application.id)}