import { useEffect, useRef } from 'react'; import useOutsideClick from '../../_shared/useOutsideClick'; export const RenamePopup = ({ value, onChange, onClose, className = '', }: { value: string; onChange: (newTitle: string) => void; onClose: () => void; className?: string; }) => { const ref = useRef(null); const inputRef = useRef(null); useOutsideClick(ref, () => onClose && onClose()); useEffect(() => { if (!inputRef || !inputRef.current) return; const { current: el } = inputRef; el.focus(); el.selectionStart = 0; el.selectionEnd = el.value.length; }, [inputRef]); return (
onChange(e.target.value)} />
); };