a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix autofocus on ios

+15 -4
+15 -4
components/Input.tsx
··· 12 12 useEffect(() => { 13 13 if (!isIOS()) return; 14 14 if (props.autoFocus) { 15 + let fakeInput = document.createElement("input"); 16 + fakeInput.setAttribute("type", "text"); 17 + fakeInput.style.position = "fixed"; 18 + fakeInput.style.height = "0px"; 19 + fakeInput.style.width = "0px"; 20 + fakeInput.style.fontSize = "16px"; // disable auto zoom 21 + document.body.appendChild(fakeInput); 22 + fakeInput.focus(); 15 23 setTimeout(() => { 16 24 if (!ref.current) return; 17 25 ref.current.style.transform = "translateY(-2000px)"; 18 26 ref.current?.focus(); 27 + fakeInput.remove(); 19 28 ref.current.value = " "; 20 29 ref.current.setSelectionRange(1, 1); 30 + requestAnimationFrame(() => { 31 + if (ref.current) { 32 + ref.current.style.transform = ""; 33 + } 34 + }); 21 35 setTimeout(() => { 22 36 if (!ref.current) return; 23 37 ref.current.value = ""; 24 38 ref.current.setSelectionRange(0, 0); 25 - }, 10); 26 - requestAnimationFrame(() => { 27 - if (ref.current) ref.current.style.transform = ""; 28 - }); 39 + }, 50); 29 40 }, 20); 30 41 } 31 42 }, [props.autoFocus]);