From 1541428ab12173a475acb3e1b94efd129e62b31a Mon Sep 17 00:00:00 2001 From: Giovanni Giordano Date: Thu, 9 Jan 2020 16:30:18 +0100 Subject: [PATCH] Clear active tool on escape (#286) * Clear active tool on escape * Remove console log --- src/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 6e3804ec..556aa933 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -167,13 +167,19 @@ export class App extends React.Component<{}, AppState> { }; private onKeyDown = (event: KeyboardEvent) => { - if (isInputLike(event.target)) return; - if (event.key === KEYS.ESCAPE) { elements = clearSelection(elements); this.forceUpdate(); + this.setState({ elementType: 'selection' }); + if (window.document.activeElement instanceof HTMLElement) { + window.document.activeElement.blur() + } event.preventDefault(); - } else if (event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE) { + return; + } + if (isInputLike(event.target)) return; + + if (event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE) { this.deleteSelectedElements(); event.preventDefault(); } else if (isArrowKey(event.key)) {