Explorar o código

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

Shun Miyazawa %!s(int64=4) %!d(string=hai) anos
pai
achega
0f61927e59
Modificáronse 1 ficheiros con 9 adicións e 4 borrados
  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;
     }
   };