Simplify detection of meta key in tandem with enter key

Thanks @lukevmorris for the tip
pull/10616/head
Alex P 2018-02-07 10:21:08 -08:00
parent 45b4469974
commit a9d85dc02c
1 changed files with 2 additions and 25 deletions

View File

@ -60,8 +60,6 @@ class CellEditorOverlay extends Component {
axes,
colorSingleStatText: colorsTypeContainsText,
colors: validateColors(colors, type, colorsTypeContainsText),
metaKeyDown: false,
enterKeyDown: false,
}
}
@ -449,29 +447,9 @@ 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) {
if (e.key === 'Enter' && e.metaKey && 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 === 'Escape' && e.target === this.overlayRef) {
this.props.onCancel()
}
@ -510,7 +488,6 @@ class CellEditorOverlay extends Component {
<div
className={OVERLAY_TECHNOLOGY}
onKeyDown={this.handleHotKeyDown}
onKeyUp={this.handleHotKeyUp}
tabIndex="0"
ref={r => (this.overlayRef = r)}
>