Просмотр исходного кода

don't let props.onPressEnter run when the Enter key is pressed

Shun Miyazawa 4 лет назад
Родитель
Сommit
0f61927e59
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      packages/app/src/components/Common/ClosableTextInput.tsx

+ 9 - 4
packages/app/src/components/Common/ClosableTextInput.tsx

@@ -52,13 +52,18 @@ const ClosableTextInput: FC<ClosableTextInputProps> = memo((props: ClosableTextI
     }
 
     const text = inputText != null ? inputText.trim() : null;
-
-    props.onPressEnter(text);
+    if (currentAlertInfo == null) {
+      props.onPressEnter(text);
+    }
   };
 
   const onKeyDownHandler = (e) => {
-    if (e.key === 'Enter' && currentAlertInfo == null) {
-      onPressEnter();
+    switch (e.key) {
+      case 'Enter':
+        onPressEnter();
+        break;
+      default:
+        break;
     }
   };