From 80c04048d06323d13813b1db0a0d3b6c05b7e11a Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 29 Oct 2015 21:30:29 +0000 Subject: [PATCH] cancel viewsource dialog with escape --- src/skins/vector/views/organisms/ViewSource.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/skins/vector/views/organisms/ViewSource.js b/src/skins/vector/views/organisms/ViewSource.js index a00cfc85c..5916967d0 100644 --- a/src/skins/vector/views/organisms/ViewSource.js +++ b/src/skins/vector/views/organisms/ViewSource.js @@ -21,6 +21,22 @@ var React = require('react'); module.exports = React.createClass({ displayName: 'ViewSource', + componentDidMount: function() { + document.addEventListener("keydown", this.onKeyDown); + }, + + componentWillUnmount: function() { + document.removeEventListener("keydown", this.onKeyDown); + }, + + onKeyDown: function(ev) { + if (ev.keyCode == 27) { // escape + ev.stopPropagation(); + ev.preventDefault(); + this.props.onFinished(); + } + }, + render: function() { return (