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: retain sheet opener and route focus around urgent toasts
Amruth Pillaifdc5bb58eb80
diff --git a/apps/web/src/components/layout/navigation-focus.test.tsx b/apps/web/src/components/layout/navigation-focus.test.tsxindex 7ae7c7352..d3a91ac99 100644--- a/apps/web/src/components/layout/navigation-focus.test.tsx+++ b/apps/web/src/components/layout/navigation-focus.test.tsx@@ -54,7 +54,7 @@ it.each(["dialog", "alertdialog"] as const)("retains initial %s focus when its rexpect(screen.getByRole("textbox")).toHaveFocus();});-it.each([false, true])(+it.each([undefined, "low", "high"] as const)("updates route focus despite a nonmodal toast (%s), retaining field focus for search changes",async (toast) => {const notifications = Toast.createToastManager();@@ -96,16 +96,16 @@ it.each([false, true])(await waitFor(() => expect(screen.getByRole("heading", { name: "One" })).toHaveFocus());if (toast) {act(() => {- notifications.add({ description: "Account created", timeout: 0 });+ notifications.add({ description: "Account created", timeout: 0, priority: toast });});- await screen.findByText("Account created");+ await screen.findByRole(toast === "high" ? "alertdialog" : "dialog", { hidden: true });}- await router.navigate({ to: "/two" });+ await act(() => router.navigate({ to: "/two" }));await waitFor(() => expect(screen.getByRole("heading", { name: "Two" })).toHaveFocus());expect(document.title).toBe("Two | Reactive Resume");const field = screen.getByRole("textbox", { name: "Search" });field.focus();- await router.navigate({ to: "/two", search: { q: "retained" } });+ await act(() => router.navigate({ to: "/two", search: { q: "retained" } }));await act(() => new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))),);diff --git a/apps/web/src/components/layout/navigation-focus.tsx b/apps/web/src/components/layout/navigation-focus.tsxindex 19a7c0e72..98eab2f53 100644--- a/apps/web/src/components/layout/navigation-focus.tsx+++ b/apps/web/src/components/layout/navigation-focus.tsx@@ -9,7 +9,7 @@ export function NavigationFocus() {const frame = requestAnimationFrame(() => {if (document.querySelector(- '[role="dialog"]:not([data-closed]):not([data-slot="toast"]), [role="alertdialog"]:not([data-closed]), dialog[open]',+ '[role="dialog"]:not([data-closed]):not([data-slot="toast"]), [role="alertdialog"]:not([data-closed]):not([data-slot="toast"]), dialog[open]',))return;diff --git a/apps/web/src/routes/dashboard/applications/index.tsx b/apps/web/src/routes/dashboard/applications/index.tsxindex e14686274..10eb67540 100644--- a/apps/web/src/routes/dashboard/applications/index.tsx+++ b/apps/web/src/routes/dashboard/applications/index.tsx@@ -113,6 +113,8 @@ function RouteComponent() {const [query, setQuery] = useState(q);const overlayScope = `applications-overlay-${useId()}`;const pageRef = useRef<HTMLDivElement>(null);+ const collectionRef = useRef<HTMLDivElement>(null);+ const openingControl = useRef<HTMLElement | null>(null);const searchRef = useRef<HTMLInputElement>(null);const [capture, setCapture] = useState(takePostingCapture);const [adding, setAdding] = useState(!!capture);@@ -247,6 +249,9 @@ function RouteComponent() {const empty = !!applications && applications.length === 0;// Hoisted so the compiler keeps one function; inline, it changes with every keystroke and re-renders each row.const openApplication = (application: ApplicationSummary) => {+ const focused = document.activeElement;+ if (!openingControl.current && focused instanceof HTMLElement && pageRef.current?.contains(focused))+ openingControl.current = focused;hydrateApplicationDetail(queryClient, application);setSelectedId(application.id);};@@ -278,6 +283,11 @@ function RouteComponent() {return (<divref={pageRef}+ onClickCapture={(event) => {+ const trigger =+ event.target instanceof Element ? event.target.closest<HTMLElement>("[data-application-open]") : null;+ if (trigger) openingControl.current = trigger;+ }}tabIndex={-1}className="mx-auto grid w-full max-w-[1180px] content-start gap-5 px-8 py-8 max-sm:px-4 max-sm:py-5">@@ -507,6 +517,7 @@ function RouteComponent() {) : (<divkey={shown}+ ref={collectionRef}className={cn(viewSwitched? "transition-[opacity,translate] duration-standard ease-enter starting:translate-y-1 starting:opacity-0"@@ -583,9 +594,18 @@ function RouteComponent() {/><ApplicationDetailSheetreturnFocus={(id) => {+ const trigger = openingControl.current;+ openingControl.current = null;if (editing || adding) return null;+ if (+ trigger?.isConnected &&+ trigger.getClientRects().length > 0 &&+ trigger.closest<HTMLElement>("[data-application-id]")?.dataset.applicationId === id+ )+ return trigger;const rows = Array.from(- pageRef.current?.querySelectorAll<HTMLElement>("[data-application-id] [data-application-open]") ?? [],+ collectionRef.current?.querySelectorAll<HTMLElement>("[data-application-id] [data-application-open]") ??+ [],).filter((row) => row.getClientRects().length > 0);const row =rows.find((item) => item.closest<HTMLElement>("[data-application-id]")?.dataset.applicationId === id) ??diff --git a/docs/guides/managing-an-application.mdx b/docs/guides/managing-an-application.mdxindex 84183555b..0a53d8420 100644--- a/docs/guides/managing-an-application.mdx+++ b/docs/guides/managing-an-application.mdx@@ -14,7 +14,7 @@ Use the details sheet to manage one application, and its workspace to work on fiAt the top you see the role, the company and location, and **View posting** when a posting was saved. **View posting** shows the saved posting text and what the job asks for, or opens the job link if only a link was saved.-On short landscape browser windows, the application header and stage controls scroll with the details. The footer actions stay at the bottom. When a newly saved job opens, focus moves to its title; closing the sheet returns focus to its row. If that row is gone or filtered out, focus moves to another visible row or the Applications heading.+On short landscape browser windows, the application header and stage controls scroll with the details. The footer actions stay at the bottom. When a newly saved job opens, focus moves to its title; closing the sheet returns focus to its row. A sheet opened from a row or follow-up nudge returns to that control while it remains visible. If the control is gone or filtered out, focus moves to the application's visible row, another visible row or the Applications heading.<Frame caption="Short landscape browser: details scroll while footer actions stay visible"><imgdiff --git a/tests/e2e/specs/deferred-accessibility.spec.ts b/tests/e2e/specs/deferred-accessibility.spec.tsindex bff86a811..9b84b33ec 100644--- a/tests/e2e/specs/deferred-accessibility.spec.ts+++ b/tests/e2e/specs/deferred-accessibility.spec.ts@@ -1,5 +1,35 @@import { expect, test } from "../fixtures/test";+test("sheet returns to its actual opener when a nudge and list row share an application", async ({+ authPage: page,+}) => {+ await expect(+ await page.request.post("/api/openapi/applications", {+ data: {+ role: "Accessibility Engineer",+ company: "Fictional Workshop",+ status: "applied",+ followUpAt: new Date(Date.now() - 86_400_000).toISOString(),+ followUpDateOnly: false,+ },+ }),+ ).toBeOK();+ await page.goto("/dashboard/applications");+ const nudge = page.getByRole("button", { name: "Open", exact: true });+ await expect(nudge).toBeVisible();+ const row = page.locator("[data-application-open]").filter({ hasText: "Accessibility Engineer" });+ await row.focus();+ await row.press("Enter");+ const sheet = page.getByRole("dialog", { name: "Accessibility Engineer", exact: true });+ await expect(sheet).toBeVisible();+ await page.keyboard.press("Escape");+ await expect(row).toBeFocused();+ await nudge.click();+ await expect(sheet).toBeVisible();+ await page.keyboard.press("Escape");+ await expect(nudge).toBeFocused();+});+test("new application focuses its title and returns to its surviving row", async ({ authPage: page }) => {await page.goto("/dashboard/applications");await page.getByRole("button", { name: "Save job", exact: true }).first().click();