From a9d85dc02c2aefd8ff6b3f5042c18c4db185ecae Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 7 Feb 2018 10:21:08 -0800 Subject: [PATCH] Simplify detection of meta key in tandem with enter key Thanks @lukevmorris for the tip --- .../components/CellEditorOverlay.js | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/ui/src/dashboards/components/CellEditorOverlay.js b/ui/src/dashboards/components/CellEditorOverlay.js index 201b1b14e5..e3539217fd 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.js +++ b/ui/src/dashboards/components/CellEditorOverlay.js @@ -60,8 +60,6 @@ class CellEditorOverlay extends Component { axes, colorSingleStatText: colorsTypeContainsText, colors: validateColors(colors, type, colorsTypeContainsText), - metaKeyDown: false, - enterKeyDown: false, } } @@ -449,28 +447,8 @@ class CellEditorOverlay extends Component { } handleHotKeyDown = e => { - if (e.key === 'Meta') { - this.setState({metaKeyDown: true}) - } - if (e.key === 'Enter') { - this.setState({enterKeyDown: true}) - } - } - - handleHotKeyUp = e => { - if (e.key === 'Meta') { - this.setState({metaKeyDown: false}) - - if (this.state.enterKeyDown === true && e.target === this.overlayRef) { - this.handleSaveCell() - } - } - if (e.key === 'Enter') { - this.setState({enterKeyDown: false}) - - if (this.state.metaKeyDown === true && e.target === this.overlayRef) { - this.handleSaveCell() - } + if (e.key === 'Enter' && e.metaKey && e.target === this.overlayRef) { + this.handleSaveCell() } if (e.key === 'Escape' && e.target === this.overlayRef) { this.props.onCancel() @@ -510,7 +488,6 @@ class CellEditorOverlay extends Component {
(this.overlayRef = r)} >