fix type to focus not working after room switch (#1866)
authorAjay Bura <32841439+ajbura@users.noreply.github.com>
Sun, 4 Aug 2024 06:04:11 +0000 (11:34 +0530)
committerGitHub <noreply@github.com>
Sun, 4 Aug 2024 06:04:11 +0000 (16:04 +1000)
src/app/features/room/RoomInput.tsx

index 2728a54c8e84273f4202de51bf17fb901d273cfa..8375d2f75a79556b07016a92a62473f68a483a03 100644 (file)
@@ -186,9 +186,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
       Transforms.insertFragment(editor, msgDraft);
     }, [editor, msgDraft]);
 
-    useEffect(() => {
-      if (!mobileOrTablet()) ReactEditor.focus(editor);
-      return () => {
+    useEffect(
+      () => () => {
         if (!isEmptyEditor(editor)) {
           const parsedDraft = JSON.parse(JSON.stringify(editor.children));
           setMsgDraft(parsedDraft);
@@ -197,8 +196,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
         }
         resetEditor(editor);
         resetEditorHistory(editor);
-      };
-    }, [roomId, editor, setMsgDraft]);
+      },
+      [roomId, editor, setMsgDraft]
+    );
 
     const handleRemoveUpload = useCallback(
       (upload: TUploadContent | TUploadContent[]) => {