Merge pull request #3509 from matrix-org/bwindels/createroomenter

Fix: submit create room dialog when pressing enter
pull/21833/head
Bruno Windels 2019-10-08 16:36:05 +00:00 committed by GitHub
commit 14bbaae585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -73,6 +73,14 @@ export default createReactClass({
this._detailsRef.removeEventListener("toggle", this.onDetailsToggled);
},
_onKeyDown: function(event) {
if (event.key === "Enter") {
this.onOk();
event.preventDefault();
event.stopPropagation();
}
},
onOk: async function() {
const activeElement = document.activeElement;
if (activeElement) {
@ -176,7 +184,7 @@ export default createReactClass({
<BaseDialog className="mx_CreateRoomDialog" onFinished={this.props.onFinished}
title={title}
>
<form onSubmit={this.onOk}>
<form onSubmit={this.onOk} onKeyDown={this._onKeyDown}>
<div className="mx_Dialog_content">
<Field id="name" ref={ref => this._nameFieldRef = ref} label={ _t('Name') } onChange={this.onNameChange} onValidate={this.onNameValidate} value={this.state.name} className="mx_CreateRoomDialog_name" />
<Field id="topic" label={ _t('Topic (optional)') } onChange={this.onTopicChange} value={this.state.topic} />