Browse Source

Refactored

Taichi Masuyama 4 years ago
parent
commit
6a656a58b1
1 changed files with 11 additions and 4 deletions
  1. 11 4
      packages/app/src/components/Sidebar/PageTree/ClosableTextInput.tsx

+ 11 - 4
packages/app/src/components/Sidebar/PageTree/ClosableTextInput.tsx

@@ -35,10 +35,7 @@ const ClosableTextInput: FC<ClosableTextInputProps> = memo((props: ClosableTextI
     setAlertInfo(alertInfo);
   };
 
-  const onKeyDownHandler = (e) => {
-    if (e.key !== 'Enter') {
-      return;
-    }
+  const onPressEnter = () => {
     if (props.onPressEnter == null) {
       return;
     }
@@ -46,6 +43,16 @@ const ClosableTextInput: FC<ClosableTextInputProps> = memo((props: ClosableTextI
     props.onPressEnter();
   };
 
+  const onKeyDownHandler = (e) => {
+    switch (e.key) {
+      case 'Enter':
+        onPressEnter();
+        break;
+      default:
+        break;
+    }
+  };
+
   /*
    * Hide when click outside the ref
    */