From 972d69da6cbf5ec1f660144718d9cad8d1290b06 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Wed, 5 Feb 2020 19:07:53 +0100 Subject: [PATCH] fix hotkeys not working when non-writable input focused (#717) --- src/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index b7342e92..2a25ff0d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -387,7 +387,11 @@ export class App extends React.Component { }; private onKeyDown = (event: KeyboardEvent) => { - if (isInputLike(event.target) && event.key !== KEYS.ESCAPE) { + if ( + (isWritableElement(event.target) && event.key !== KEYS.ESCAPE) || + // case: using arrows to move between buttons + (isArrowKey(event.key) && isInputLike(event.target)) + ) { return; } @@ -438,6 +442,9 @@ export class App extends React.Component { if (!isHoldingSpace) { setCursorForShape(shape); } + if (document.activeElement instanceof HTMLElement) { + document.activeElement.blur(); + } elements = clearSelection(elements); this.setState({ elementType: shape }); // Undo action