mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 21:55:20 +08:00
InputEnabled submits form with ENTER
This commit is contained in:
parent
ccd14f6b50
commit
eb0641d76a
1 changed files with 13 additions and 1 deletions
|
@ -5,6 +5,7 @@ import { FormattedMessage } from "react-intl";
|
|||
import { FormGroup, FormControl, ControlLabel, Button } from "react-bootstrap";
|
||||
|
||||
import { BORDER_LIGHT_COLOR } from "../../../../app/constants/colors";
|
||||
import { ENTER_KEY_CODE } from "../../../../app/constants/numeric";
|
||||
|
||||
const StyledInputEnabled = styled.div`
|
||||
border: 1px solid ${BORDER_LIGHT_COLOR};
|
||||
|
@ -36,6 +37,14 @@ class InputEnabled extends Component {
|
|||
this.handleChange = this.handleChange.bind(this);
|
||||
this.handleChange2 = this.handleChange2.bind(this);
|
||||
this.handleUpdate = this.handleUpdate.bind(this);
|
||||
this.handleKeyPress = this.handleKeyPress.bind(this);
|
||||
}
|
||||
|
||||
handleKeyPress(event) {
|
||||
if (event.charCode === ENTER_KEY_CODE) {
|
||||
event.preventDefault();
|
||||
this.handleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
handleChange(event) {
|
||||
|
@ -89,7 +98,8 @@ class InputEnabled extends Component {
|
|||
<FormControl
|
||||
type={this.props.inputType}
|
||||
value={this.state.value}
|
||||
onChange={this.handleChange}
|
||||
onKeyPress={this.handleKeyPress}
|
||||
autoFocus
|
||||
/>
|
||||
<p>New password confirmation</p>
|
||||
<FormControl
|
||||
|
@ -106,6 +116,8 @@ class InputEnabled extends Component {
|
|||
type={this.props.inputType}
|
||||
value={this.state.value}
|
||||
onChange={this.handleChange}
|
||||
onKeyPress={this.handleKeyPress}
|
||||
autoFocus
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue