Jelajahi Sumber

Disable escape when creating element (#576)

Problem:
- Select arrow
- Mouse down somewhere
- Mouse move somewhere to create an arrow
- Press escape
- Now you're in a weird situation where the shape is now "selection" but you're still dragging the arrow. If you mouse up, the arrow disappears

In order to solve this problem, we can avoid making escape do anything if you're currently dragging an element
Christopher Chedeau 5 tahun lalu
induk
melakukan
c3e9f775e7
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      src/index.tsx

+ 1 - 1
src/index.tsx

@@ -284,7 +284,7 @@ export class App extends React.Component<any, AppState> {
   };
   };
 
 
   private onKeyDown = (event: KeyboardEvent) => {
   private onKeyDown = (event: KeyboardEvent) => {
-    if (event.key === KEYS.ESCAPE) {
+    if (event.key === KEYS.ESCAPE && !this.state.draggingElement) {
       elements = clearSelection(elements);
       elements = clearSelection(elements);
       this.forceUpdate();
       this.forceUpdate();
       this.setState({ elementType: "selection" });
       this.setState({ elementType: "selection" });