diff --git a/src/components/CreateDirButton.tsx b/src/components/CreateDirButton.tsx index 5f1d409..7b49ea5 100644 --- a/src/components/CreateDirButton.tsx +++ b/src/components/CreateDirButton.tsx @@ -1,4 +1,5 @@ -import React from "react" +import React, { useRef } from "react" +import { useEffect } from "react" import { useState } from "react" interface Props { @@ -8,28 +9,53 @@ interface Props { const CreateDirButton: React.FC = (props) => { const [name,setName] = useState("") + const [show,setShow] = useState(false) + const input = useRef(null) + + useEffect(()=>{ + if(show){ + input.current?.focus() + } + },[show]) return (
- -
- { - setName(e.target.value) - }} - value={name} - /> - + setShow(false) + }}> + setName(e.target.value)} + value={name} + ref={input} + onBlur={()=>{ + setShow(false) + setName("") + }} + /> + {/* */} +
)