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: keep shortcut help clear of floating phone controls
Amruth Pillaife1fb02c8d97
diff --git a/apps/web/src/features/documents/trash-page.tsx b/apps/web/src/features/documents/trash-page.tsxindex 4a64f9d0c..2e2c67086 100644--- a/apps/web/src/features/documents/trash-page.tsx+++ b/apps/web/src/features/documents/trash-page.tsx@@ -1,3 +1,4 @@+import type { Ref } from "react";import { i18n } from "@lingui/core";import { ph, plural, t } from "@lingui/core/macro";import { Trans, useLingui } from "@lingui/react/macro";@@ -9,6 +10,7 @@ import { Button, buttonVariants } from "@reactive-resume/ui/components/button";import { Checkbox } from "@reactive-resume/ui/components/checkbox";import { Icon } from "@reactive-resume/ui/components/icon";import { IconButton } from "@reactive-resume/ui/components/icon-button";+import { useFloatingToolbarSpace } from "@reactive-resume/ui/hooks/use-floating-toolbar-space";import { cn } from "@reactive-resume/utils/style";import { useBatchActions } from "./document-actions";import { DocumentRow } from "./document-card";@@ -35,6 +37,7 @@ export function TrashPage() {const [busy, setBusy] = useState(false);const confirm = useConfirm();const resultsRef = useRef<HTMLTableElement>(null);+ const { ref: selectionBarRef, space: selectionBarSpace } = useFloatingToolbarSpace();const {data: page,isPending,@@ -144,7 +147,10 @@ export function TrashPage() {};return (- <div 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">+ <div+ 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"+ style={{ paddingBottom: selecting ? selectionBarSpace : undefined }}+ ><PageHeaderback={<Link@@ -257,6 +263,7 @@ export function TrashPage() {}}/><TrashSelectionBar+ ref={selectionBarRef}selection={selection}allSelected={allSelected}busy={busy}@@ -270,6 +277,7 @@ export function TrashPage() {}type TrashSelectionBarProps = {+ ref: Ref<HTMLDivElement>;selection: { type: string; id: string; name: string }[];allSelected: boolean;busy: boolean;@@ -281,6 +289,7 @@ type TrashSelectionBarProps = {/** Floats over Trash while rows are selected: Restore or Delete permanently the selected loaded documents. */function TrashSelectionBar({+ ref,selection,allSelected,busy,@@ -293,12 +302,13 @@ function TrashSelectionBar({return (<div+ ref={ref}role="toolbar"aria-label={t`Selected documents in Trash`}aria-hidden={count === 0}inert={count === 0}className={cn(- "fixed inset-x-0 bottom-6 z-30 mx-auto flex w-fit max-w-[calc(100vw-32px)] items-center gap-1 rounded-xl border border-line bg-raised p-1.5 shadow-e3 transition-[opacity,translate] duration-standard ease-enter max-sm:bottom-4",+ "fixed inset-x-0 bottom-6 z-30 mx-auto flex w-fit max-w-[calc(100vw-32px)] items-center gap-1 rounded-xl border border-line bg-raised p-1.5 shadow-e3 transition-[opacity,translate] duration-standard ease-enter max-sm:bottom-[calc(69px+env(safe-area-inset-bottom))]",count === 0 && "pointer-events-none translate-y-2 opacity-0",)}>diff --git a/apps/web/src/features/keyboard-shortcuts/index.tsx b/apps/web/src/features/keyboard-shortcuts/index.tsxindex 44b39781d..6b8a0185b 100644--- a/apps/web/src/features/keyboard-shortcuts/index.tsx+++ b/apps/web/src/features/keyboard-shortcuts/index.tsx@@ -42,7 +42,7 @@ export function KeyboardShortcuts() {<Buttonid="keyboard-shortcuts-trigger"variant="secondary"- className="fixed end-3 bottom-20 z-30 gap-2 sm:bottom-3 print:hidden"+ className="fixed end-3 bottom-[max(5rem,var(--floating-toolbar-clearance,0px))] z-30 gap-2 sm:bottom-[max(0.75rem,var(--floating-toolbar-clearance,0px))] print:hidden"onClick={() => showKeyboardShortcuts()}aria-keyshortcuts={characterShortcuts ? "?" : undefined}>diff --git a/apps/web/src/features/resume/editor/chrome.tsx b/apps/web/src/features/resume/editor/chrome.tsxindex 64e614a17..bc3f737bc 100644--- a/apps/web/src/features/resume/editor/chrome.tsx+++ b/apps/web/src/features/resume/editor/chrome.tsx@@ -11,12 +11,13 @@ import { Icon } from "@reactive-resume/ui/components/icon";import { IconButton } from "@reactive-resume/ui/components/icon-button";import { Tooltip, TooltipContent, TooltipTrigger } from "@reactive-resume/ui/components/tooltip";import { useBreakpoint } from "@reactive-resume/ui/hooks/use-breakpoint";+import { useFloatingToolbarSpace } from "@reactive-resume/ui/hooks/use-floating-toolbar-space";import { cn } from "@reactive-resume/utils/style";import { clampZoom, FIT_MAX, useEditorStore, ZOOM_MAX, ZOOM_MIN, ZOOM_STEP } from "./store";import { anchoredScroll, wheelZoom, type ZoomAnchor } from "./zoom-wheel";import { applicationsListQueryOptions } from "@/features/applications/queries";import { useLetterEditorStore } from "@/features/letters/store";-import { useResumeStore } from "@/features/resume/builder/draft";+import { usePreviewPausedStore, useResumeStore } from "@/features/resume/builder/draft";// The editor chrome resumes and letters share: the back link and drawer controls in the bar, the canvas width// and the zoom bar.@@ -346,6 +347,8 @@ type ZoomBarProps = {*/export function ZoomBar({ fitScale, pageCount }: ZoomBarProps) {const { t } = useLingui();+ const { ref } = useFloatingToolbarSpace();+ const paused = usePreviewPausedStore((state) => state.paused);const zoom = useEditorStore((state) => state.zoom);const setZoom = useEditorStore((state) => state.setZoom);const current = zoom === "fit" ? fitScale : zoom;@@ -366,7 +369,10 @@ export function ZoomBar({ fitScale, pageCount }: ZoomBarProps) {"touch-target relative flex size-8 items-center justify-center rounded-lg text-ink-2 transition-colors duration-quick hover:bg-hover disabled:text-ink-3 disabled:hover:bg-transparent";return (- <div className="absolute bottom-[18px] left-1/2 flex -translate-x-1/2 items-center gap-0.5 rounded-lg border border-line bg-raised p-1 shadow-e2 pointer-coarse:gap-1.5">+ <div+ ref={paused ? undefined : ref}+ className="absolute bottom-[18px] left-1/2 flex -translate-x-1/2 items-center gap-0.5 rounded-lg border border-line bg-raised p-1 shadow-e2 pointer-coarse:gap-1.5"+ ><buttontype="button"aria-label={t`Zoom out`}diff --git a/apps/web/src/routes/builder/$resumeId/-components/editor-shell.tsx b/apps/web/src/routes/builder/$resumeId/-components/editor-shell.tsxindex 436bf312a..79d390f8e 100644--- a/apps/web/src/routes/builder/$resumeId/-components/editor-shell.tsx+++ b/apps/web/src/routes/builder/$resumeId/-components/editor-shell.tsx@@ -5,6 +5,7 @@ import { getRouteApi, Outlet } from "@tanstack/react-router";import { Suspense, useCallback, useEffect } from "react";import { Icon } from "@reactive-resume/ui/components/icon";import { Tabs, TabsContent } from "@reactive-resume/ui/components/tabs";+import { useFloatingToolbarSpace } from "@reactive-resume/ui/hooks/use-floating-toolbar-space";import { cn } from "@reactive-resume/utils/style";import { DownloadSheet } from "./download-sheet";import { EditorBar } from "./editor-bar";@@ -196,10 +197,14 @@ function MobileBody({ mode, onModeChange }: MobileBodyProps) {/** Phones: tapping a line on the page selects it and offers to edit that entry. Improve joins it in M10. */function SelectionBar({ onEdit }: { onEdit: () => void }) {const selection = useEditorStore((state) => state.selection);+ const { ref } = useFloatingToolbarSpace();if (!selection) return null;return (- <div className="absolute bottom-[76px] left-1/2 z-10 flex -translate-x-1/2 items-center rounded-xl bg-ink p-1 text-bg shadow-e3 transition-[opacity,translate] duration-standard ease-enter starting:translate-y-2 starting:opacity-0">+ <div+ ref={ref}+ className="absolute bottom-[76px] left-1/2 z-10 flex -translate-x-1/2 items-center rounded-xl bg-ink p-1 text-bg shadow-e3 transition-[opacity,translate] duration-standard ease-enter starting:translate-y-2 starting:opacity-0"+ ><buttontype="button"className="flex h-10 items-center gap-1.5 rounded-lg px-3 text-[15px] font-semibold"diff --git a/docs/guides/managing-documents.mdx b/docs/guides/managing-documents.mdxindex d702733aa..4272ebcd1 100644--- a/docs/guides/managing-documents.mdx+++ b/docs/guides/managing-documents.mdx@@ -126,6 +126,15 @@ After duplication, choose **Rename** in the confirmation to edit the new copy. OTick a document's checkbox (in list view, or on a card's top corner; on touch screens the box is always shown), or choose **Select** from its menu. A bar appears at the bottom of the page, above the tab bar on phones, with **Tags…**, **Sharing** and **Move to Trash**. The page leaves room to scroll the final row above the bar. **Sharing** can lock or unlock documents; public and private links apply to resumes only. **Select this page** adds the rest of the page; the **×** or <kbd>Esc</kbd> clears the selection.+**Keyboard shortcuts** stays above the selection bar, so you can open help while keeping every bulk action reachable.++<Frame caption="Shortcut help and bulk actions stay separate on a phone">+ <img+ src="/images/guides/managing-documents/selection-bar-phone.png"+ alt="Fictional Alder selected in the phone Documents list, with Keyboard shortcuts above the Tags, Sharing, Clear selection and Move to Trash buttons, and the app tabs below."+ />+</Frame>+<Frame caption="The final row remains above the selection bar"><imgsrc="/images/guides/managing-documents/selection-bar.png"diff --git a/docs/images/guides/managing-documents/selection-bar-phone.png b/docs/images/guides/managing-documents/selection-bar-phone.pngnew file mode 100644index 000000000..e9d2bced2Binary files /dev/null and b/docs/images/guides/managing-documents/selection-bar-phone.png differdiff --git a/packages/ui/src/hooks/use-floating-toolbar-space.test.tsx b/packages/ui/src/hooks/use-floating-toolbar-space.test.tsxnew file mode 100644index 000000000..cdaf12350--- /dev/null+++ b/packages/ui/src/hooks/use-floating-toolbar-space.test.tsx@@ -0,0 +1,43 @@+import { act, renderHook, waitFor } from "@testing-library/react";+import { expect, it } from "vite-plus/test";+import { useFloatingToolbarSpace } from "./use-floating-toolbar-space";++it("retains the newer toolbar's clearance when an outgoing owner unmounts, then releases it when hidden", async () => {+ const first = renderHook(useFloatingToolbarSpace);+ const second = renderHook(useFloatingToolbarSpace);+ const bars = [80, 120].map((height) => {+ const element = document.createElement("div");+ element.style.bottom = "69px";+ Object.defineProperty(element, "offsetHeight", { value: height });+ element.getBoundingClientRect = () => new DOMRect(0, window.innerHeight - height - 69, 200, height);+ document.body.append(element);+ return element;+ });+ const [firstBar, secondBar] = bars;+ if (!firstBar || !secondBar) throw new Error("Both toolbar owners are required.");+ const clearance = () => document.documentElement.style.getPropertyValue("--floating-toolbar-clearance");+ let detachFirst: (() => void) | undefined;+ let detachSecond: (() => void) | undefined;+ try {+ act(() => {+ detachFirst = first.result.current.ref(firstBar);+ detachSecond = second.result.current.ref(secondBar);+ });+ expect(clearance()).toBe("205px");+ act(() => detachFirst?.());+ expect(clearance()).toBe("205px");+ secondBar.setAttribute("aria-hidden", "true");+ await waitFor(() => expect(clearance()).toBe(""));+ secondBar.setAttribute("aria-hidden", "false");+ await waitFor(() => expect(clearance()).toBe("205px"));+ } finally {+ act(() => {+ detachFirst?.();+ detachSecond?.();+ });+ first.unmount();+ second.unmount();+ for (const element of bars) element.remove();+ }+ expect(clearance()).toBe("");+});diff --git a/packages/ui/src/hooks/use-floating-toolbar-space.tsx b/packages/ui/src/hooks/use-floating-toolbar-space.tsxindex 31980e586..72b7b486c 100644--- a/packages/ui/src/hooks/use-floating-toolbar-space.tsx+++ b/packages/ui/src/hooks/use-floating-toolbar-space.tsx@@ -1,19 +1,42 @@import { useCallback, useState } from "react";+const clearances = new Map<HTMLDivElement, number>();+const updateClearance = () => {+ const clearance = Math.max(0, ...clearances.values());+ const style = document.documentElement.style;+ if (clearance) style.setProperty("--floating-toolbar-clearance", `${clearance}px`);+ else style.removeProperty("--floating-toolbar-clearance");+};+/** Room to scroll the last row above a fixed toolbar, including wrapped labels and its bottom inset. */export function useFloatingToolbarSpace() {const [space, setSpace] = useState(0);const ref = useCallback((element: HTMLDivElement | null) => {if (!element) return;- const measure = () =>- setSpace(element.offsetHeight + (Number.parseFloat(getComputedStyle(element).bottom) || 0) + 16);+ const measure = () => {+ const space = element.offsetHeight + (Number.parseFloat(getComputedStyle(element).bottom) || 0) + 16;+ setSpace(space);+ clearances.set(+ element,+ element.offsetHeight && element.getAttribute("aria-hidden") !== "true"+ ? Math.max(space, window.innerHeight - element.getBoundingClientRect().top + 16)+ : 0,+ );+ updateClearance();+ };measure();const observer = new ResizeObserver(measure);observer.observe(element);+ if (element.parentElement) observer.observe(element.parentElement);+ const visibility = new MutationObserver(measure);+ visibility.observe(element, { attributes: true, attributeFilter: ["aria-hidden"] });window.addEventListener("resize", measure);return () => {observer.disconnect();+ visibility.disconnect();window.removeEventListener("resize", measure);+ clearances.delete(element);+ updateClearance();};}, []);return { ref, space };diff --git a/tests/e2e/specs/floating-shortcut-help.spec.ts b/tests/e2e/specs/floating-shortcut-help.spec.tsnew file mode 100644index 000000000..341bc2ca6--- /dev/null+++ b/tests/e2e/specs/floating-shortcut-help.spec.ts@@ -0,0 +1,124 @@+import type { Locator } from "@playwright/test";+import { expect, test } from "../fixtures/test";++test.use({ hasTouch: true });++async function receivesPointer(control: Locator) {+ return control.evaluate((element) => {+ const rect = element.getBoundingClientRect();+ return element.contains(document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2));+ });+}++for (const { width, rtl, largeText } of [+ { width: 320, rtl: true, largeText: false },+ { width: 390, rtl: false, largeText: false },+ { width: 390, rtl: false, largeText: true },+]) {+ test(`phone document actions and shortcut help stay reachable at ${width}px (RTL=${rtl}, large=${largeText})`, async ({+ authPage: page,+ }, info) => {+ await page.setViewportSize({ width, height: 844 });+ const created = await page.request.post("/api/openapi/resumes", {+ data: { name: "Fictional Alder", tags: [] },+ });+ await expect(created).toBeOK();+ await page.goto("/dashboard?view=list");+ await page.evaluate(+ ({ rtl, largeText }) => {+ if (rtl) document.documentElement.dir = "rtl";+ if (largeText) document.documentElement.style.fontSize = "24px";+ },+ { rtl, largeText },+ );+ await page.getByRole("checkbox", { name: "Select Fictional Alder", exact: true }).click();+ const bar = page.getByRole("toolbar", { name: "Selected documents", exact: true });+ const help = page.getByRole("button", { name: "Keyboard shortcuts", exact: true });+ await expect(bar).toBeVisible();+ for (const name of ["Tags…", "Sharing", "Clear selection", "Move to Trash"]) {+ const control = bar.getByRole("button", { name, exact: true });+ await expect(control).toBeVisible();+ await expect.poll(() => receivesPointer(control)).toBe(true);+ }+ await expect.poll(() => receivesPointer(help)).toBe(true);+ await help.click();+ const dialog = page.getByRole("dialog", { name: "Keyboard shortcuts", exact: true });+ await expect(dialog.getByText("Search documents", { exact: true })).toBeVisible();+ await dialog.getByRole("button", { name: "Close", exact: true }).click();+ await expect(help).toBeFocused();+ await page.screenshot({ path: info.outputPath("document-actions-and-help.png"), animations: "disabled" });+ await bar.getByRole("button", { name: "Move to Trash", exact: true }).tap();+ await expect(page.getByText("1 document moved to Trash", { exact: true })).toBeVisible();+ const response = await page.request.get("/api/openapi/documents/counts");+ await expect(response).toBeOK();+ const counts = await response.json();+ expect(counts).toMatchObject({ resume: 0, trash: 1 });+ await page.getByRole("button", { name: "Undo", exact: true }).click();+ await expect(page.getByRole("checkbox", { name: "Select Fictional Alder", exact: true })).toBeVisible();+ });+}++test("application bulk actions retain pointer access and help clears a dismissed toolbar", async ({+ authPage: page,+}) => {+ await page.setViewportSize({ width: 390, height: 844 });+ await expect(+ await page.request.post("/api/openapi/applications", {+ data: { company: "Fictional Harbor", role: "Systems lead", status: "saved" },+ }),+ ).toBeOK();+ await page.goto("/dashboard/applications?view=list");+ const row = page.getByRole("button", { name: "Systems lead Fictional Harbor · Not applied yet", exact: true });+ await row.focus();+ await row.press("x");+ const bar = page.getByRole("toolbar", { name: "Applications", exact: true });+ const help = page.getByRole("button", { name: "Keyboard shortcuts", exact: true });+ await expect(bar).toBeVisible();+ for (const control of await bar.getByRole("button").all()) {+ await expect(control).toBeVisible();+ await expect.poll(() => receivesPointer(control)).toBe(true);+ }+ await expect.poll(() => receivesPointer(help)).toBe(true);+ await bar.getByRole("button", { name: "Clear selection", exact: true }).click();+ await expect(bar).toHaveCount(0);+ await expect+ .poll(() =>+ page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue("--floating-toolbar-clearance")),+ )+ .toBe("");+ await help.click();+ await expect(page.getByRole("dialog", { name: "Keyboard shortcuts", exact: true })).toBeVisible();+});++test("Trash restore and editor controls retain their existing clearance after leaving Documents", async ({+ authPage: page,+}) => {+ await page.setViewportSize({ width: 390, height: 844 });+ const response = await page.request.post("/api/openapi/resumes", {+ data: { name: "Fictional Harbor resume", tags: [] },+ });+ await expect(response).toBeOK();+ const id = (await response.json()) as string;+ await expect(await page.request.delete(`/api/openapi/resumes/${id}`)).toBeOK();+ await page.goto("/dashboard/trash");+ await page.getByRole("checkbox", { name: "Select Fictional Harbor resume", exact: true }).click();+ const bar = page.getByRole("toolbar", { name: "Selected documents in Trash", exact: true });+ for (const control of await bar.getByRole("button").all())+ await expect.poll(() => receivesPointer(control)).toBe(true);+ await bar.getByRole("button", { name: "Restore", exact: true }).tap();+ await expect(page.getByText("1 document restored", { exact: true })).toBeVisible();+ await page.goto(`/builder/${id}`);+ await page+ .getByRole("navigation", { name: "Editor views", exact: true })+ .getByRole("button", { name: "Page", exact: true })+ .click();+ for (const name of ["Zoom out", "Fit page to width", "Zoom in"])+ await expect.poll(() => receivesPointer(page.getByRole("button", { name, exact: true }))).toBe(true);+ const help = page.getByRole("button", { name: "Keyboard shortcuts", exact: true });+ await expect.poll(() => receivesPointer(help)).toBe(true);+ await help.click();+ const dialog = page.getByRole("dialog", { name: "Keyboard shortcuts", exact: true });+ await expect(dialog.getByText("Download PDF", { exact: true })).toBeVisible();+ await dialog.getByRole("button", { name: "Close", exact: true }).click();+ await expect(help).toBeFocused();+});