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 some keyboard / input focusing stuff in link block

+11 -3
+11 -3
components/Blocks/ExternalLinkBlock.tsx
··· 9 9 import { useSmoker } from "components/Toast"; 10 10 import { CheckTiny, LinkSmall } from "components/Icons"; 11 11 import { Separator } from "components/Layout"; 12 - import { Input } from "components/Input"; 12 + import { focusElement, Input } from "components/Input"; 13 13 import { isUrl } from "src/utils/isURL"; 14 14 import { elementId } from "src/utils/elementId"; 15 15 import { deleteBlock } from "./DeleteBlock"; ··· 30 30 useEffect(() => { 31 31 if (props.preview) return; 32 32 let input = document.getElementById(elementId.block(props.entityID).input); 33 + console.log(isSelected, input); 33 34 if (isSelected) { 34 - input?.focus(); 35 + setTimeout(() => { 36 + let input = document.getElementById( 37 + elementId.block(props.entityID).input, 38 + ); 39 + focusElement(input as HTMLInputElement | null); 40 + }, 20); 35 41 } else input?.blur(); 36 42 }, [isSelected, props.entityID, props.preview]); 37 43 ··· 39 45 if (!permissions.write) return null; 40 46 return ( 41 47 <label 42 - id={props.preview ? undefined : elementId.block(props.entityID).input} 43 48 className={` 44 49 w-full h-[104px] p-2 45 50 text-tertiary hover:text-accent-contrast hover:cursor-pointer ··· 163 168 /> 164 169 <Separator /> 165 170 <Input 171 + id={elementId.block(props.entityID).input} 166 172 type="url" 167 173 disabled={isLocked} 168 174 className="w-full grow border-none outline-none bg-transparent " ··· 171 177 onChange={(e) => setLinkValue(e.target.value)} 172 178 onKeyDown={(e) => { 173 179 if (e.key === "Backspace" && linkValue === "") { 180 + e.preventDefault(); 174 181 rep && deleteBlock([props.entityID].flat(), rep); 175 182 return; 176 183 } 177 184 if (e.key === "Enter") { 185 + e.preventDefault(); 178 186 if (!linkValue) return; 179 187 if (!isUrl(linkValue)) { 180 188 let rect = e.currentTarget.getBoundingClientRect();