mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
Merge pull request #867 from matrix-org/t3chguy/BaseDialog-patch1
Fixes 2 issues with Dialog closing
This commit is contained in:
commit
3549ff2543
1 changed files with 12 additions and 3 deletions
|
@ -57,20 +57,25 @@ export default React.createClass({
|
|||
}
|
||||
},
|
||||
|
||||
// Don't let key{down,press} events escape the modal. Consume them all.
|
||||
_eatKeyEvent: function(e) {
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
// Must be when the key is released (and not pressed) otherwise componentWillUnmount
|
||||
// will focus another element which will receive future key events
|
||||
_onKeyUp: function(e) {
|
||||
if (e.keyCode === KeyCode.ESCAPE) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
this.props.onFinished();
|
||||
} else if (e.keyCode === KeyCode.ENTER) {
|
||||
if (this.props.onEnterPressed) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
this.props.onEnterPressed(e);
|
||||
}
|
||||
}
|
||||
// Consume all keyup events while Modal is open
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
_onCancelClick: function(e) {
|
||||
|
@ -81,7 +86,11 @@ export default React.createClass({
|
|||
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||
|
||||
return (
|
||||
<div onKeyUp={this._onKeyUp} className={this.props.className}>
|
||||
<div onKeyUp={this._onKeyUp}
|
||||
onKeyDown={this._eatKeyEvent}
|
||||
onKeyPress={this._eatKeyEvent}
|
||||
className={this.props.className}
|
||||
>
|
||||
<AccessibleButton onClick={this._onCancelClick}
|
||||
className="mx_Dialog_cancelButton"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue