diff --git a/ui/editor/components/link-selector.tsx b/ui/editor/components/link-selector.tsx index 1629dcd1f..f50c8b69a 100644 --- a/ui/editor/components/link-selector.tsx +++ b/ui/editor/components/link-selector.tsx @@ -16,26 +16,19 @@ export const LinkSelector: FC = ({ }) => { const inputRef = useRef(null); + // Autofocus on input by default useEffect(() => { inputRef.current && inputRef.current?.focus(); - }, [isOpen]); - - const handleLinkSubmission = () => { - const url = getUrlFromString(inputRef.current?.value || ""); - if (url) { - editor.chain().focus().setLink({ href: url }).run(); - setIsOpen(false); - } - }; + }); return (
{isOpen && ( -
+
{ + e.preventDefault(); + const input = e.target[0] as HTMLInputElement; + const url = getUrlFromString(input.value); + url && editor.chain().focus().setLink({ href: url }).run(); + setIsOpen(false); + }} + className="fixed top-full z-[99999] mt-1 flex w-60 overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1" + > = ({ /> {editor.getAttributes("link").href ? ( ) : ( - )} -
+ )}
);