Prevent form submit on enter without JavaScript

This commit is contained in:
Maciej Ziarkowski 2021-03-16 19:00:54 +00:00
parent 4433041d0d
commit c9176f96ac
2 changed files with 2 additions and 2 deletions

View File

@ -64,8 +64,6 @@ export const DataEntryInput: React.FC<TextDataEntryInputProps & {value?: string}
placeholder={props.placeholder}
onKeyDown={e => {
if(e.keyCode === 13) {
// prevent form submit on enter
e.preventDefault();
if(props.confirmOnEnter) {
handleConfirm();
}

View File

@ -364,6 +364,8 @@ const withCopyEdit: (wc: React.ComponentType<CategoryViewProps>) => DataContaine
action={`/edit/${this.props.cat}/${this.props.building.building_id}`}
method="POST"
onSubmit={this.handleSubmit}>
{/* this disabled button prevents form submission on enter - see https://stackoverflow.com/a/51507806/1478817 */}
<button type="submit" disabled style={{display: 'none'}}></button>
{
(this.props.mode === 'edit' && !this.props.inactive) ?
<div className='edit-bar'>