Browse Source

fix hotkeys not working when non-writable input focused (#717)

David Luzar 5 years ago
parent
commit
972d69da6c
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/index.tsx

+ 8 - 1
src/index.tsx

@@ -387,7 +387,11 @@ export class App extends React.Component<any, AppState> {
   };
   };
 
 
   private onKeyDown = (event: KeyboardEvent) => {
   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;
       return;
     }
     }
 
 
@@ -438,6 +442,9 @@ export class App extends React.Component<any, AppState> {
       if (!isHoldingSpace) {
       if (!isHoldingSpace) {
         setCursorForShape(shape);
         setCursorForShape(shape);
       }
       }
+      if (document.activeElement instanceof HTMLElement) {
+        document.activeElement.blur();
+      }
       elements = clearSelection(elements);
       elements = clearSelection(elements);
       this.setState({ elementType: shape });
       this.setState({ elementType: shape });
       // Undo action
       // Undo action