keep the focus at end on initial load
This commit is contained in:
parent
e95305c1a0
commit
c3e508a8f9
1 changed files with 8 additions and 1 deletions
|
|
@ -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<HTMLDivElement, CustomEditorProps>(
|
|||
},
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!initialValue?.length) return;
|
||||
|
||||
Transforms.select(editor, Editor.end(editor, []));
|
||||
}, [editor, initialValue]);
|
||||
|
||||
const renderElement = useCallback(
|
||||
(props: RenderElementProps) => <RenderElement {...props} />,
|
||||
[]
|
||||
|
|
|
|||
Loading…
Reference in a new issue