allow form submit with enter key

This commit is contained in:
Sean Yesmunt 2018-09-10 15:54:48 -04:00
parent ca5d8e15cf
commit 051dcb8454
3 changed files with 8 additions and 5 deletions

View file

@ -1,8 +1,9 @@
import React from 'react';
const ButtonPrimary = ({ value, onClickHandler }) => {
const ButtonPrimary = ({ value, onClickHandler, type = 'button' }) => {
return (
<button
type={type}
className={'button button-primary'}
onClick={onClickHandler}
>

View file

@ -59,7 +59,7 @@ class ChannelCreateForm extends React.Component {
return (
<div>
{ !status ? (
<div>
<form onSubmit={this.handleSubmit}>
<ChannelCreateNameInput
value={name.value}
error={name.error}
@ -74,10 +74,11 @@ class ChannelCreateForm extends React.Component {
defaultMessage={'Choose a name and password for your channel'}
/>
<ButtonPrimary
type={'submit'}
value={'Create Channel'}
onClickHandler={this.handleSubmit}
/>
</div>
</form>
) : (
<div>
<p className={'text--small text--secondary'}>{status}</p>

View file

@ -49,7 +49,7 @@ class ChannelLoginForm extends React.Component {
}
render () {
return (
<div>
<form onSubmit={this.loginToChannel}>
<ChannelLoginNameInput
channelName={this.state.channelName}
handleInput={this.handleInput}
@ -63,10 +63,11 @@ class ChannelLoginForm extends React.Component {
defaultMessage={'Enter the name and password for your channel'}
/>
<ButtonPrimary
type={'submit'}
value={'Authenticate'}
onClickHandler={this.loginToChannel}
/>
</div>
</form>
);
}
}