From 78e72723440780814fced82cc8a2406c47992464 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@googlemail.com> Date: Sun, 7 May 2017 20:43:42 +0100 Subject: [PATCH 1/4] Fixes 2 issues with Dialog closing + Upload Confirmation dialog would just change focus on ESC and not close + Keywords Dialog in UserSettings would also close UserSettings because event bubbled up --- src/components/views/dialogs/BaseDialog.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/views/dialogs/BaseDialog.js b/src/components/views/dialogs/BaseDialog.js index 279dedbd43..d567a0ba9a 100644 --- a/src/components/views/dialogs/BaseDialog.js +++ b/src/components/views/dialogs/BaseDialog.js @@ -57,6 +57,12 @@ export default React.createClass({ } }, + // Don't let key down events get any further, so they only trigger this and nothing more + _onKeyDown: function(e) { + e.stopPropagation(); + e.preventDefault(); + }, + // 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) { @@ -81,7 +87,7 @@ export default React.createClass({ const TintableSvg = sdk.getComponent("elements.TintableSvg"); return ( -
+
From 360f1cd250378a54d0305464111b2af57fb79731 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@googlemail.com> Date: Sun, 7 May 2017 20:57:54 +0100 Subject: [PATCH 2/4] completely missed the ESC check I need sleep --- src/components/views/dialogs/BaseDialog.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/BaseDialog.js b/src/components/views/dialogs/BaseDialog.js index d567a0ba9a..e7b8a687f5 100644 --- a/src/components/views/dialogs/BaseDialog.js +++ b/src/components/views/dialogs/BaseDialog.js @@ -59,8 +59,10 @@ export default React.createClass({ // Don't let key down events get any further, so they only trigger this and nothing more _onKeyDown: function(e) { - e.stopPropagation(); - e.preventDefault(); + if (e.keyCode === KeyCode.ESCAPE) { + e.stopPropagation(); + e.preventDefault(); + } }, // Must be when the key is released (and not pressed) otherwise componentWillUnmount From bd32df4ef6dbf66f1ba5d9b23117fefbe2132c72 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@googlemail.com> Date: Sun, 7 May 2017 20:58:30 +0100 Subject: [PATCH 3/4] comment wording --- src/components/views/dialogs/BaseDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/BaseDialog.js b/src/components/views/dialogs/BaseDialog.js index e7b8a687f5..ac36dfd056 100644 --- a/src/components/views/dialogs/BaseDialog.js +++ b/src/components/views/dialogs/BaseDialog.js @@ -57,7 +57,7 @@ export default React.createClass({ } }, - // Don't let key down events get any further, so they only trigger this and nothing more + // Don't let esc keydown events get any further, so they only trigger this and nothing more _onKeyDown: function(e) { if (e.keyCode === KeyCode.ESCAPE) { e.stopPropagation(); From f02e659fb7502ebb524651494e9c9bd1098fcc9b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@googlemail.com> Date: Tue, 9 May 2017 11:27:06 +0100 Subject: [PATCH 4/4] Consume key{up,down,pressed} events so they don't trigger other things bubbling up until Modal is closed --- src/components/views/dialogs/BaseDialog.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/views/dialogs/BaseDialog.js b/src/components/views/dialogs/BaseDialog.js index ac36dfd056..02460148b3 100644 --- a/src/components/views/dialogs/BaseDialog.js +++ b/src/components/views/dialogs/BaseDialog.js @@ -57,28 +57,25 @@ export default React.createClass({ } }, - // Don't let esc keydown events get any further, so they only trigger this and nothing more - _onKeyDown: function(e) { - if (e.keyCode === KeyCode.ESCAPE) { - e.stopPropagation(); - e.preventDefault(); - } + // 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) { @@ -89,7 +86,11 @@ export default React.createClass({ const TintableSvg = sdk.getComponent("elements.TintableSvg"); return ( -
+