diff --git a/src/components/core/FormInput.tsx b/src/components/core/FormInput.tsx index 91fd08d9..00f69eb5 100644 --- a/src/components/core/FormInput.tsx +++ b/src/components/core/FormInput.tsx @@ -1,4 +1,4 @@ -import { useState, CSSProperties } from 'react' +import { useState, CSSProperties, SyntheticEvent } from 'react' import styled from 'styled-components' import { StyledInput } from './Input' @@ -17,16 +17,23 @@ interface FormInputProps { export function FormInput({ onSubmit, style }: FormInputProps) { const [value, setValue] = useState('') + const handleSubmit = (event: SyntheticEvent) => { + event.preventDefault() + onSubmit(value) + setValue('') + } + return ( setValue(e.target.value)} + onKeyDown={(e) => e.key === 'Enter' && handleSubmit(e)} style={{ gridColumn: '1/4', gridRow: '1/1', paddingRight: 96 }} /> onSubmit(value)} + onClick={handleSubmit} style={{ gridArea: '1/2' }} > Add