Simplify detection of meta key in tandem with enter key
Thanks @lukevmorris for the tippull/10616/head
parent
45b4469974
commit
a9d85dc02c
|
@ -60,8 +60,6 @@ class CellEditorOverlay extends Component {
|
||||||
axes,
|
axes,
|
||||||
colorSingleStatText: colorsTypeContainsText,
|
colorSingleStatText: colorsTypeContainsText,
|
||||||
colors: validateColors(colors, type, colorsTypeContainsText),
|
colors: validateColors(colors, type, colorsTypeContainsText),
|
||||||
metaKeyDown: false,
|
|
||||||
enterKeyDown: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,29 +447,9 @@ class CellEditorOverlay extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotKeyDown = e => {
|
handleHotKeyDown = e => {
|
||||||
if (e.key === 'Meta') {
|
if (e.key === 'Enter' && e.metaKey && e.target === this.overlayRef) {
|
||||||
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()
|
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) {
|
if (e.key === 'Escape' && e.target === this.overlayRef) {
|
||||||
this.props.onCancel()
|
this.props.onCancel()
|
||||||
}
|
}
|
||||||
|
@ -510,7 +488,6 @@ class CellEditorOverlay extends Component {
|
||||||
<div
|
<div
|
||||||
className={OVERLAY_TECHNOLOGY}
|
className={OVERLAY_TECHNOLOGY}
|
||||||
onKeyDown={this.handleHotKeyDown}
|
onKeyDown={this.handleHotKeyDown}
|
||||||
onKeyUp={this.handleHotKeyUp}
|
|
||||||
tabIndex="0"
|
tabIndex="0"
|
||||||
ref={r => (this.overlayRef = r)}
|
ref={r => (this.overlayRef = r)}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue