fix(webui): keep touch form fields readable without focus zoom

This commit is contained in:
Xubin Ren committed 2026-10-04 20:26:15 +08:00
1 parent 3ff76cd808
commit 948ce38246
7 files changed
+63 -4

No files matched your search

+4
View File
@@ -207,6 +207,10 @@ magnified area; normal fitting resumes when
you return to the default zoom. Non-touch desktop and native-host layout remain
unchanged.
On touch devices, compact text fields use a readable 16px minimum baseline to
avoid Safari automatically zooming the page on focus. Desktop field density
and manual page zoom remain unchanged.
On touch devices, preview tab controls and
the full-screen image viewer's close button use larger touch areas without
enlarging the icons. Preview tabs remain horizontally scrollable when space is
+1 -1
View File
@@ -91,7 +91,7 @@ function HostMenuItems({ picker }: { picker: HostPicker }) {
<Search aria-hidden className="h-4 w-4 shrink-0 text-muted-foreground" />
<input ref={search} aria-label={t("remote.searchHosts")} placeholder={t("remote.searchHosts")}
value={query} onChange={(event) => setQuery(event.target.value)} autoComplete="off" spellCheck={false}
className="h-7 min-w-0 flex-1 bg-transparent text-[13px] outline-none placeholder:text-muted-foreground" />
className="touch-text-input h-7 min-w-0 flex-1 bg-transparent text-[13px] outline-none placeholder:text-muted-foreground" />
</div> : <DropdownMenuLabel className="shrink-0">{t("remote.switchHost")}</DropdownMenuLabel>}
<div ref={list} role="group" aria-label={t("remote.switchHost")}
className="min-h-0 overflow-y-auto overscroll-contain scrollbar-thin scrollbar-track-transparent">
@@ -83,7 +83,7 @@ export function PromptNavigator({
aria-label={t("thread.promptNavigator.search")}
placeholder={t("thread.promptNavigator.search")}
className={cn(
"h-10 w-full rounded-full border border-border bg-background pl-9 pr-3 text-sm",
"touch-text-input h-10 w-full rounded-full border border-border bg-background pl-9 pr-3 text-sm",
"transition-colors",
formControlFocusClassName,
)}
+1 -1
View File
@@ -11,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={cn(
"flex h-10 w-full rounded-full border border-input bg-background px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
"touch-text-input flex h-10 w-full rounded-full border border-input bg-background px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
formControlFocusClassName,
className,
)}
+1 -1
View File
@@ -10,7 +10,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
return (
<textarea
className={cn(
"flex min-h-[60px] w-full rounded-control border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
"touch-text-input flex min-h-[60px] w-full rounded-control border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
formControlFocusClassName,
className,
)}
+8
View File
@@ -885,6 +885,14 @@
}
@media (pointer: coarse) {
/* Readable form text avoids Safari's focus zoom without disabling the user's
pinch zoom. Keep this after utilities so compact desktop overrides cannot
shrink shared form fields on touch devices. Larger chat/search text stays
on its own typography; this is not a blanket rule for every input. */
.touch-text-input {
font-size: max(16px, 1rem);
}
.thread-message-row,
.message-block-menu-trigger,
[data-message-block-menu] {
+47
View File
@@ -0,0 +1,47 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { render, screen } from "@testing-library/react";
import postcss from "postcss";
import tailwindcss from "tailwindcss";
import loadConfig from "tailwindcss/loadConfig";
import { describe, expect, it } from "vitest";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
describe("touch form typography", () => {
it("keeps the touch baseline on compact shared fields without changing desktop classes", () => {
render(<>
<Input aria-label="Name" />
<Input aria-label="Address" className="text-[13px]" />
<Textarea aria-label="Pairing code" className="font-mono text-xs" />
</>);
for (const field of screen.getAllByRole("textbox")) {
expect(field).toHaveClass("touch-text-input");
}
expect(screen.getByLabelText("Name")).toHaveClass("text-sm");
expect(screen.getByLabelText("Address")).toHaveClass("text-[13px]");
expect(screen.getByLabelText("Pairing code")).toHaveClass("text-xs", "font-mono");
});
it("emits the baseline after compact utilities, only for opted-in touch fields", async () => {
const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));
const source = readFileSync(resolve(process.cwd(), "src/globals.css"), "utf8");
const result = await postcss([tailwindcss({ ...config, content: [{
raw: 'class="touch-text-input text-xs text-sm text-[13px] text-[19px]"',
}] })]).process(source, { from: undefined });
let baseline = -1;
let index = 0;
const compact: number[] = [];
result.root.walkRules((rule) => {
index++;
if ([".text-xs", ".text-sm", ".text-\\[13px\\]"].includes(rule.selector)) compact.push(index);
if (rule.selector !== ".touch-text-input") return;
baseline = index;
expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });
expect(rule.nodes).toContainEqual(expect.objectContaining({ prop: "font-size", value: "max(16px, 1rem)" }));
});
expect(compact).toHaveLength(3);
expect(baseline).toBeGreaterThan(Math.max(...compact));
});
});