1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

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

This commit is contained in:
Manuel Pitz 2018-08-31 00:28:38 +02:00 committed by Steffen Vogel
parent 56da378014
commit d9deff7b7e
2 changed files with 18 additions and 5 deletions

View file

@ -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() {

View file

@ -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>;
}
}