Skip to content

Commit

Permalink
Merge pull request #11 from Xundan91/Feature/NewFileDialog_AddedEnter…
Browse files Browse the repository at this point in the history
…Binding

Feature/new file dialog : Added Enter KeyBinding To dialogBox
  • Loading branch information
ankushKun authored Jun 19, 2024
2 parents 26e0952 + 21ff09f commit a406311
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion next_app/src/components/new-file-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export function NewFileDialog({ manager, project, collapsed, setCollapsed }: { m
setPopupOpen(false);
setCollapsed(true);
}
const handleEnter =( event :React.KeyboardEvent<HTMLInputElement> ) =>{
if(event.key === "Enter"){
newFile();
}

}

return (
<Dialog open={popupOpen} onOpenChange={(e) => { setPopupOpen(e); setCollapsed(!e)}}>
Expand All @@ -40,7 +46,7 @@ export function NewFileDialog({ manager, project, collapsed, setCollapsed }: { m
<DialogTitle>Create a new file</DialogTitle>
<DialogDescription>Enter the name of the file you want to create<br/>(supported extensions: lua, luanb, md)</DialogDescription>
</DialogHeader>
<Input type="text" placeholder="File Name" onChange={(e) => setNewFileName(e.target.value)} />
<Input type="text" placeholder="File Name" onChange={(e) => setNewFileName(e.target.value)} onKeyDown={handleEnter}/>
<Button onClick={() => newFile()}>Create File</Button>
</DialogContent>
</Dialog>
Expand Down

0 comments on commit a406311

Please sign in to comment.