From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sun, 4 Aug 2024 06:04:11 +0000 (+0530) Subject: fix type to focus not working after room switch (#1866) X-Git-Tag: v4.1.0~1 X-Git-Url: https://git.wafflesoft.org/?a=commitdiff_plain;h=cabfdd47b5bf1c9a12c6d30a9c28fed6d6682fb9;p=rainny.git fix type to focus not working after room switch (#1866) --- diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 2728a54..8375d2f 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -186,9 +186,8 @@ export const RoomInput = forwardRef( 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( } resetEditor(editor); resetEditorHistory(editor); - }; - }, [roomId, editor, setMsgDraft]); + }, + [roomId, editor, setMsgDraft] + ); const handleRemoveUpload = useCallback( (upload: TUploadContent | TUploadContent[]) => {