From 5256da36314e7e4fa6a9265784d43dcd07e5da9c Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 20 Aug 2021 17:02:18 +0200 Subject: [PATCH] create dir button layout --- src/components/CreateDirButton.tsx | 58 +++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 16 deletions(-) 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("") + }} + /> + {/* */} +
)