Commit d9deff7b authored by Manuel Pitz's avatar Manuel Pitz Committed by Steffen Vogel
Browse files

activate enter handling and add function to prevent key handling when needed

parent 56da3780
......@@ -31,13 +31,21 @@ class Dialog extends React.Component {
this.props.onClose(true);
}
/**
* To prevent Enter hanlding user onKeyPress={this.handleKeyIgnore} in that form element
* and the following handler in the corresponding file:
*
* //this function prevents a keystroke from beeing handled by dialog.js
* handleKeyIgnore(event){
* event.stopPropagation();
* }
*/
onKeyPress = (event) => {
/*if (event.key === 'Enter') {
if (event.key === 'Enter') {
// prevent input from submitting
event.preventDefault();
this.closeModal(false);
}*/
}
}
render() {
......
......@@ -31,15 +31,20 @@ class EditWidgetHTMLContent extends React.Component {
};
}
handleKeyIgnore(event){
// This function prevents a keystroke from beeing handled by dialog.js
event.stopPropagation();
}
componentWillReceiveProps(nextProps) {
// Update state's widget with props
// Update state's widget with props
this.setState({ widget: nextProps.widget });
}
render() {
return <FormGroup controlId={this.props.controlId}>
<ControlLabel>HTML Content</ControlLabel>
<FormControl componentClass="textarea" style={{ height: 200 }} placeholder={this.props.placeholder} value={this.state.widget[this.props.controlId] || ''} onChange={e => this.props.handleChange(e)} />
<FormControl onKeyPress={this.handleKeyIgnore} componentClass="textarea" style={{ height: 200 }} placeholder={this.props.placeholder} value={this.state.widget[this.props.controlId] || ''} onChange={e => this.props.handleChange(e)} />
</FormGroup>;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment