diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 76b85862e..e66aca928 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -113,6 +113,10 @@ const MarkdownTextInput = React.forwardRef( const setEventProps = useCallback((e: NativeSyntheticEvent) => { if (divRef.current) { const text = divRef.current.value; + if (e.target) { + // TODO: change the logic here so every event have value property + (e.target as unknown as HTMLInputElement).value = text; + } if (e.nativeEvent && e.nativeEvent.text) { e.nativeEvent.text = text; } @@ -526,7 +530,7 @@ const MarkdownTextInput = React.forwardRef( parseText(divRef.current, value, processedMarkdownStyle); updateTextColor(divRef.current, value); }, - [multiline, processedMarkdownStyle], + [multiline, processedMarkdownStyle, value], ); useClientEffect( diff --git a/src/web/utils/cursorUtils.ts b/src/web/utils/cursorUtils.ts index 46e35b4e0..77e18db52 100644 --- a/src/web/utils/cursorUtils.ts +++ b/src/web/utils/cursorUtils.ts @@ -3,7 +3,7 @@ import {findHTMLElementInTree, getTreeNodeByIndex} from './treeUtils'; function setCursorPosition(target: MarkdownTextInputElement, start: number, end: number | null = null) { // We don't want to move the cursor if the target is not focused - if (target !== document.activeElement || start < 0 || (end && end < 0)) { + if (!target.tree || target !== document.activeElement || start < 0 || (end && end < 0)) { return; }