diff --git a/src/components/profile/editor-viewer.tsx b/src/components/profile/editor-viewer.tsx index 186815ed1..64f2e1675 100644 --- a/src/components/profile/editor-viewer.tsx +++ b/src/components/profile/editor-viewer.tsx @@ -103,7 +103,7 @@ export const EditorViewer = (props: Props) => { [initialData], ); - const editorRef = useRef(null); + const editorRef = useRef(undefined); const prevData = useRef(""); const currData = useRef(""); @@ -126,8 +126,9 @@ export const EditorViewer = (props: Props) => { }); }; - const handleChange = useLockFn(async (value: string | undefined) => { + const handleChange = useLockFn(async (_value?: string) => { try { + const value = editorRef.current?.getValue(); currData.current = value; onChange?.(prevData.current, currData.current); } catch (err) { @@ -138,6 +139,7 @@ export const EditorViewer = (props: Props) => { const handleSave = useLockFn(async () => { try { if (!readOnly) { + currData.current = editorRef.current?.getValue(); onSave?.(prevData.current, currData.current); } onClose(); @@ -175,12 +177,12 @@ export const EditorViewer = (props: Props) => { return () => { unlistenResized.then((fn) => fn()); editorRef.current?.dispose(); - editorRef.current = null; + editorRef.current = undefined; }; }, [editorResize]); return ( - + {resolvedTitle}