Phones: no AutoFill bar over text boxes, steadier scrolling above the keyboard
- Text boxes say autocomplete="off" (the forum's in the markup, any other textarea when it gets the focus), so iOS Safari does not lay its AutoFill bar (passwords, cards, addresses) over them. - KeyboardSafe scrolls at once instead of smoothly (the browser's own scroll cut the smooth one short on iOS), once more when that has settled, and keeps a little more room 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:
@@ -55,6 +55,7 @@ export default async function SearchPage({ searchParams }: { searchParams: Promi
|
|||||||
id="fsearch-q"
|
id="fsearch-q"
|
||||||
name="q"
|
name="q"
|
||||||
type="search"
|
type="search"
|
||||||
|
autoComplete="off"
|
||||||
className="inp"
|
className="inp"
|
||||||
defaultValue={q}
|
defaultValue={q}
|
||||||
placeholder="Mit keresel? Például: alvás, telihold, gyász"
|
placeholder="Mit keresel? Például: alvás, telihold, gyász"
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ export function NewThreadForm({
|
|||||||
onChange={(e) => withEmoji(e, setTitle)}
|
onChange={(e) => withEmoji(e, setTitle)}
|
||||||
maxLength={120}
|
maxLength={120}
|
||||||
required
|
required
|
||||||
|
autoComplete="off"
|
||||||
placeholder="Adj címet a szálnak…"
|
placeholder="Adj címet a szálnak…"
|
||||||
/>
|
/>
|
||||||
<label htmlFor="fnew-body" className="sr-only">
|
<label htmlFor="fnew-body" className="sr-only">
|
||||||
@@ -200,6 +201,7 @@ export function NewThreadForm({
|
|||||||
onChange={(e) => withEmoji(e, setBody)}
|
onChange={(e) => withEmoji(e, setBody)}
|
||||||
maxLength={10000}
|
maxLength={10000}
|
||||||
required
|
required
|
||||||
|
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…"}
|
||||||
/>
|
/>
|
||||||
<div className="fnew-foot">
|
<div className="fnew-foot">
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ function typedInto(el: Element | null): el is HTMLElement {
|
|||||||
* menu and other fixed bars step aside), `--vv-top` and `--vv-height` give
|
* menu and other fixed bars step aside), `--vv-top` and `--vv-height` give
|
||||||
* the part of the screen the keyboard leaves free (for full-screen panels),
|
* the part of the screen the keyboard leaves free (for full-screen panels),
|
||||||
* and the field, with its send button when the form is small, is scrolled
|
* and the field, with its send button when the form is small, is scrolled
|
||||||
* into that part.
|
* into that part. A text box gets `autocomplete="off"` unless it says
|
||||||
|
* otherwise, so iOS Safari does not lay its AutoFill bar (passwords, cards,
|
||||||
|
* addresses) over it.
|
||||||
*/
|
*/
|
||||||
export function KeyboardSafe() {
|
export function KeyboardSafe() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -35,6 +37,7 @@ export function KeyboardSafe() {
|
|||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
const vv = window.visualViewport;
|
const vv = window.visualViewport;
|
||||||
let timer: number | undefined;
|
let timer: number | undefined;
|
||||||
|
let again: number | undefined;
|
||||||
let closing: number | undefined;
|
let closing: number | undefined;
|
||||||
|
|
||||||
const measure = () => {
|
const measure = () => {
|
||||||
@@ -51,26 +54,33 @@ export function KeyboardSafe() {
|
|||||||
const form = el.closest("form");
|
const form = el.closest("form");
|
||||||
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 - 12 };
|
const free = { top: top + 12, bottom: top + height - 16 };
|
||||||
if (rect.bottom > free.bottom) {
|
let delta = 0;
|
||||||
window.scrollBy({ top: Math.min(rect.bottom - free.bottom, rect.top - free.top), behavior: "smooth" });
|
if (rect.bottom > free.bottom) delta = Math.min(rect.bottom - free.bottom, rect.top - free.top);
|
||||||
} else if (rect.top < free.top) {
|
else if (rect.top < free.top) delta = rect.top - free.top;
|
||||||
window.scrollBy({ top: rect.top - free.top, behavior: "smooth" });
|
// At once: a smooth scroll would be cut short by the browser's own one.
|
||||||
}
|
if (Math.abs(delta) > 2) window.scrollBy({ top: delta, behavior: "instant" });
|
||||||
};
|
};
|
||||||
|
|
||||||
// After the keyboard has slid up, and again whenever the free part changes.
|
// After the keyboard has slid up (and once more when the browser's own
|
||||||
|
// scrolling has settled), and whenever the free part changes.
|
||||||
const later = (ms: number) => {
|
const later = (ms: number) => {
|
||||||
window.clearTimeout(timer);
|
window.clearTimeout(timer);
|
||||||
|
window.clearTimeout(again);
|
||||||
timer = window.setTimeout(reveal, ms);
|
timer = window.setTimeout(reveal, ms);
|
||||||
|
again = window.setTimeout(reveal, ms + 450);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFocusIn = (e: FocusEvent) => {
|
const onFocusIn = (e: FocusEvent) => {
|
||||||
if (!typedInto(e.target as Element)) return;
|
const field = e.target as Element;
|
||||||
|
if (field instanceof HTMLTextAreaElement && !field.hasAttribute("autocomplete")) {
|
||||||
|
field.setAttribute("autocomplete", "off");
|
||||||
|
}
|
||||||
|
if (!typedInto(field)) return;
|
||||||
window.clearTimeout(closing);
|
window.clearTimeout(closing);
|
||||||
root.classList.add("kb-open");
|
root.classList.add("kb-open");
|
||||||
measure();
|
measure();
|
||||||
later(350);
|
later(300);
|
||||||
};
|
};
|
||||||
const onFocusOut = () => {
|
const onFocusOut = () => {
|
||||||
// Moving to another field keeps it open.
|
// Moving to another field keeps it open.
|
||||||
@@ -82,7 +92,7 @@ export function KeyboardSafe() {
|
|||||||
const onViewport = () => {
|
const onViewport = () => {
|
||||||
if (!root.classList.contains("kb-open")) return;
|
if (!root.classList.contains("kb-open")) return;
|
||||||
measure();
|
measure();
|
||||||
later(120);
|
later(150);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener("focusin", onFocusIn);
|
document.addEventListener("focusin", onFocusIn);
|
||||||
@@ -91,6 +101,7 @@ export function KeyboardSafe() {
|
|||||||
vv?.addEventListener("scroll", measure);
|
vv?.addEventListener("scroll", measure);
|
||||||
return () => {
|
return () => {
|
||||||
window.clearTimeout(timer);
|
window.clearTimeout(timer);
|
||||||
|
window.clearTimeout(again);
|
||||||
window.clearTimeout(closing);
|
window.clearTimeout(closing);
|
||||||
document.removeEventListener("focusin", onFocusIn);
|
document.removeEventListener("focusin", onFocusIn);
|
||||||
document.removeEventListener("focusout", onFocusOut);
|
document.removeEventListener("focusout", onFocusOut);
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ export function Composer({
|
|||||||
if (e.key === "Escape") setSuggest(null);
|
if (e.key === "Escape") setSuggest(null);
|
||||||
}}
|
}}
|
||||||
maxLength={10000}
|
maxLength={10000}
|
||||||
|
autoComplete="off"
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
aria-autocomplete={mentions ? "list" : undefined}
|
aria-autocomplete={mentions ? "list" : undefined}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user