1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-05 05:40:06 +00:00

fix: autofocus input field and submit on enter

This commit is contained in:
2022-07-28 23:55:59 +05:00
parent 8de032b543
commit 7681722e5a
3 changed files with 53 additions and 25 deletions

View File

@@ -39,21 +39,30 @@ const FilePathInputModal = ({
setFilePath(value)
}
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
if (hasError || !filePath) return
saveFile(filePath)
}
return (
<BootstrapDialog fullWidth onClose={() => setOpen(false)} open={open}>
<BootstrapDialogTitle id="abort-modal" handleOpen={setOpen}>
Save File
</BootstrapDialogTitle>
<DialogContent dividers>
<TextField
fullWidth
variant="outlined"
label="File Path"
value={filePath}
onChange={handleChange}
error={hasError}
helperText={errorText}
/>
<form onSubmit={handleSubmit}>
<TextField
fullWidth
autoFocus
variant="outlined"
label="File Path"
value={filePath}
onChange={handleChange}
error={hasError}
helperText={errorText}
/>
</form>
</DialogContent>
<DialogActions>
<Button variant="contained" onClick={() => setOpen(false)}>
@@ -61,9 +70,7 @@ const FilePathInputModal = ({
</Button>
<Button
variant="contained"
onClick={() => {
saveFile(filePath)
}}
onClick={() => saveFile(filePath)}
disabled={hasError || !filePath}
>
Save