diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 891b6b9c..6675e1fe 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -310,9 +310,7 @@ const MarkdownTextInput = React.forwardRef( return; } - const hostNode = (divRef.current.firstChild as HTMLElement) ?? divRef.current; - const newWidth = hostNode.offsetWidth; - const newHeight = hostNode.offsetHeight; + const {offsetWidth: newWidth, offsetHeight: newHeight} = divRef.current; if (newHeight !== dimensions.current?.height || newWidth !== dimensions.current.width) { dimensions.current = {height: newHeight, width: newWidth}; @@ -569,6 +567,11 @@ const MarkdownTextInput = React.forwardRef( } }, [autoFocus]); + useEffect(() => { + // update content size when the input styles change + handleContentSizeChange(); + }, [handleContentSizeChange, inputStyles]); + useEffect(() => { if (!divRef.current || !selection || (contentSelection.current && selection.start === contentSelection.current.start && selection.end === contentSelection.current.end)) { return;