cancel the edit when pressing escape

This commit is contained in:
Bruno Windels 2019-05-17 15:35:14 +01:00
parent ddefeae136
commit 62b8973e72

View file

@ -107,10 +107,12 @@ export default class MessageEditor extends React.Component {
} else if (event.key === "Enter") { } else if (event.key === "Enter") {
this._sendEdit(); this._sendEdit();
event.preventDefault(); event.preventDefault();
} else if (event.key === "Escape") {
this._cancelEdit();
} }
} }
_onCancelClicked = () => { _cancelEdit = () => {
dis.dispatch({action: "edit_event", event: null}); dis.dispatch({action: "edit_event", event: null});
} }
@ -185,7 +187,7 @@ export default class MessageEditor extends React.Component {
ref={ref => this._editorRef = ref} ref={ref => this._editorRef = ref}
></div> ></div>
<div className="mx_MessageEditor_buttons"> <div className="mx_MessageEditor_buttons">
<AccessibleButton kind="secondary" onClick={this._onCancelClicked}>{_t("Cancel")}</AccessibleButton> <AccessibleButton kind="secondary" onClick={this._cancelEdit}>{_t("Cancel")}</AccessibleButton>
<AccessibleButton kind="primary" onClick={this._sendEdit}>{_t("Save")}</AccessibleButton> <AccessibleButton kind="primary" onClick={this._sendEdit}>{_t("Save")}</AccessibleButton>
</div> </div>
</div>; </div>;