Przeglądaj źródła

imprv keyDownHandler logic

Shun Miyazawa 10 miesięcy temu
rodzic
commit
680aa6ef4b

+ 4 - 5
apps/app/src/client/components/SearchTypeahead.tsx

@@ -147,12 +147,11 @@ const SearchTypeahead: ForwardRefRenderFunction<IFocusable, Props> = (props: Pro
   }, [onChange, onInputChange]);
   }, [onChange, onInputChange]);
 
 
   const keyDownHandler = useCallback((event: KeyboardEvent) => {
   const keyDownHandler = useCallback((event: KeyboardEvent) => {
-    if (event.nativeEvent.isComposing) {
-      // do nothing while composing
-      return;
-    }
-
     if (event.key === 'Enter') {
     if (event.key === 'Enter') {
+      // do nothing while composing
+      if (event.nativeEvent.isComposing) {
+        return;
+      }
       if (onSubmit != null && input != null && input.length > 0) {
       if (onSubmit != null && input != null && input.length > 0) {
         // schedule to submit with 100ms delay
         // schedule to submit with 100ms delay
         timeoutIdRef.current = setTimeout(() => onSubmit(input), DELAY_FOR_SUBMISSION);
         timeoutIdRef.current = setTimeout(() => onSubmit(input), DELAY_FOR_SUBMISSION);