Skip to content

Commit 80c0404

Browse files
committed
cancel viewsource dialog with escape
1 parent 05d96f4 commit 80c0404

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎src/skins/vector/views/organisms/ViewSource.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ var React = require('react');
2121
module.exports = React.createClass({
2222
displayName: 'ViewSource',
2323

24+
componentDidMount: function() {
25+
document.addEventListener("keydown", this.onKeyDown);
26+
},
27+
28+
componentWillUnmount: function() {
29+
document.removeEventListener("keydown", this.onKeyDown);
30+
},
31+
32+
onKeyDown: function(ev) {
33+
if (ev.keyCode == 27) { // escape
34+
ev.stopPropagation();
35+
ev.preventDefault();
36+
this.props.onFinished();
37+
}
38+
},
39+
2440
render: function() {
2541
return (
2642
<div className="mx_ViewSource">

0 commit comments

Comments
 (0)