Phones: the forum's text boxes are not in a form (no card AutoFill on iOS)

iOS Safari kept offering card and address AutoFill for the reply box and
the new thread form despite autocomplete="off": it looks at the whole
<form>. The boxes now sit in plain blocks; the button sends, and so does
Ctrl/Cmd+Enter. KeyboardSafe keeps such a block (data-kb-block) with its
send button above the keyboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-26 17:18:26 +00:00
co-authored by Claude Opus 5.5
parent a622d30b39
commit 9eff714e6a
3 changed files with 36 additions and 12 deletions
@@ -86,8 +86,8 @@ export function NewThreadForm({
if (t?.listening && intent === "") setIntent("listen"); if (t?.listening && intent === "") setIntent("listen");
} }
async function submit(e: React.FormEvent) { async function submit() {
e.preventDefault(); if (busy || !title.trim() || !body.trim() || !topic) return;
setBusy(true); setBusy(true);
setError(null); setError(null);
try { try {
@@ -109,7 +109,9 @@ export function NewThreadForm({
} }
return ( return (
<form className="fnew" onSubmit={submit}> // Not a <form>: iOS Safari offers its card and address AutoFill for the
// text boxes of a form. The button sends; Ctrl/Cmd+Enter in the text too.
<div className="fnew">
{share && ( {share && (
<div className="fnew-share"> <div className="fnew-share">
<ShareCard share={share.card} onRemove={() => setShare(null)} /> <ShareCard share={share.card} onRemove={() => setShare(null)} />
@@ -176,7 +178,7 @@ export function NewThreadForm({
{intentHint && <p className="fnew-note">{intentHint}</p>} {intentHint && <p className="fnew-note">{intentHint}</p>}
</fieldset> </fieldset>
<div className="fnew-paper"> <div className="fnew-paper" data-kb-block>
<label htmlFor="fnew-title" className="sr-only"> <label htmlFor="fnew-title" className="sr-only">
Cím Cím
</label> </label>
@@ -203,12 +205,23 @@ export function NewThreadForm({
required required
autoComplete="off" autoComplete="off"
placeholder={intent === "listen" ? "Írd le, ami benned van…" : "Írd le a gondolataidat…"} placeholder={intent === "listen" ? "Írd le, ami benned van…" : "Írd le a gondolataidat…"}
onKeyDown={(e) => {
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
void submit();
}
}}
/> />
<div className="fnew-foot"> <div className="fnew-foot">
<span className="hint"> <span className="hint">
Kérjük, tartsd be a <Link href="/aszf#forum">házirendet</Link>. Kérjük, tartsd be a <Link href="/aszf#forum">házirendet</Link>.
</span> </span>
<button type="submit" className="btn btn-primary" disabled={busy || !title.trim() || !body.trim() || !topic}> <button
type="button"
className="btn btn-primary"
disabled={busy || !title.trim() || !body.trim() || !topic}
onClick={() => void submit()}
>
{busy ? "Küldés…" : "Szál indítása"} {busy ? "Küldés…" : "Szál indítása"}
</button> </button>
</div> </div>
@@ -219,6 +232,6 @@ export function NewThreadForm({
{error} {error}
</p> </p>
)} )}
</form> </div>
); );
} }
@@ -51,7 +51,8 @@ export function KeyboardSafe() {
measure(); measure();
const top = vv ? vv.offsetTop : 0; const top = vv ? vv.offsetTop : 0;
const height = vv ? vv.height : window.innerHeight; const height = vv ? vv.height : window.innerHeight;
const form = el.closest("form"); // The box with its send button: a form, or a block marked for it.
const form = el.closest("form, [data-kb-block]");
const target = form && form.getBoundingClientRect().height < height * 0.6 ? form : el; const target = form && form.getBoundingClientRect().height < height * 0.6 ? form : el;
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
const free = { top: top + 12, bottom: top + height - 16 }; const free = { top: top + 12, bottom: top + height - 16 };
@@ -91,8 +91,7 @@ export function Composer({
}); });
} }
async function submit(e: React.FormEvent) { async function submit() {
e.preventDefault();
if (!text.trim() || busy) return; if (!text.trim() || busy) return;
const final = convertEmoticons(text, text.length, true).text; const final = convertEmoticons(text, text.length, true).text;
if (await onSubmit(final)) { if (await onSubmit(final)) {
@@ -101,8 +100,10 @@ export function Composer({
} }
} }
// Not a <form>: iOS Safari offers its card and address AutoFill for the text
// boxes of a form. The button sends; Ctrl/Cmd+Enter too.
return ( return (
<form className="fc" onSubmit={submit}> <div className="fc" data-kb-block>
<label htmlFor={id} className="sr-only"> <label htmlFor={id} className="sr-only">
{label} {label}
</label> </label>
@@ -120,6 +121,10 @@ export function Composer({
}} }}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === "Escape") setSuggest(null); if (e.key === "Escape") setSuggest(null);
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
void submit();
}
}} }}
maxLength={10000} maxLength={10000}
autoComplete="off" autoComplete="off"
@@ -150,10 +155,15 @@ export function Composer({
Mégse Mégse
</button> </button>
)} )}
<button type="submit" className="btn btn-primary btn-sm" disabled={busy || !text.trim()}> <button
type="button"
className="btn btn-primary btn-sm"
disabled={busy || !text.trim()}
onClick={() => void submit()}
>
{busy ? "Küldés…" : submitLabel} {busy ? "Küldés…" : submitLabel}
</button> </button>
</div> </div>
</form> </div>
); );
} }