From c3e508a8f95dcf7b704fc5eb5d0ca835fd6ca17e Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sun, 16 Aug 2026 12:22:29 +0530 Subject: [PATCH] keep the focus at end on initial load --- src/app/components/editor/Editor.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/components/editor/Editor.tsx b/src/app/components/editor/Editor.tsx index b869f247..1cadbc58 100644 --- a/src/app/components/editor/Editor.tsx +++ b/src/app/components/editor/Editor.tsx @@ -5,10 +5,11 @@ import React, { ReactNode, forwardRef, useCallback, + useEffect, useState, } from 'react'; import { Box, Scroll, Text } from 'folds'; -import { Descendant, Editor, createEditor } from 'slate'; +import { Descendant, Editor, Transforms, createEditor } from 'slate'; import { Slate, Editable, @@ -89,6 +90,12 @@ export const CustomEditor = forwardRef( }, ]); + useEffect(() => { + if (!initialValue?.length) return; + + Transforms.select(editor, Editor.end(editor, [])); + }, [editor, initialValue]); + const renderElement = useCallback( (props: RenderElementProps) => , []