From 8519756c8c991b0cb16ac56db692d8084a7abaac Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 16 Sep 2016 02:26:17 +0100 Subject: [PATCH] add dialog keyboard shortcuts. --- src/components/views/dialogs/ErrorDialog.js | 10 +++++++++- src/components/views/dialogs/QuestionDialog.js | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/ErrorDialog.js b/src/components/views/dialogs/ErrorDialog.js index cc400e30a6..ed48f10fd7 100644 --- a/src/components/views/dialogs/ErrorDialog.js +++ b/src/components/views/dialogs/ErrorDialog.js @@ -49,9 +49,17 @@ module.exports = React.createClass({ }; }, + onKeyDown: function(e) { + if (e.keyCode === 27) { // escape + e.stopPropagation(); + e.preventDefault(); + this.props.onFinished(false); + } + }, + render: function() { return ( -
+
{this.props.title}
diff --git a/src/components/views/dialogs/QuestionDialog.js b/src/components/views/dialogs/QuestionDialog.js index 602332e46d..1cd4d047fd 100644 --- a/src/components/views/dialogs/QuestionDialog.js +++ b/src/components/views/dialogs/QuestionDialog.js @@ -46,9 +46,22 @@ module.exports = React.createClass({ this.props.onFinished(false); }, + onKeyDown: function(e) { + if (e.keyCode === 27) { // escape + e.stopPropagation(); + e.preventDefault(); + this.props.onFinished(false); + } + else if (e.keyCode === 13) { // enter + e.stopPropagation(); + e.preventDefault(); + this.props.onFinished(true); + } + }, + render: function() { return ( -
+
{this.props.title}