From 75b5896b715cb2e9351113d909fe80105d2217a4 Mon Sep 17 00:00:00 2001 From: Red-Hide Date: Mon, 13 Oct 2025 14:01:11 +0200 Subject: [PATCH 1/3] Implement height adjustment for textarea on mount Add useEffect to adjust textarea height on mount Issue : drawdb-io#647 --- src/components/EditorCanvas/Note.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/EditorCanvas/Note.jsx b/src/components/EditorCanvas/Note.jsx index d3800f88..e975775e 100644 --- a/src/components/EditorCanvas/Note.jsx +++ b/src/components/EditorCanvas/Note.jsx @@ -1,4 +1,4 @@ -import { useMemo, useState, useRef } from "react"; +import { useMemo, useState, useRef, useEffect } from "react"; import { Action, ObjectType, Tab, State } from "../../data/constants"; import { Input, Button, Popover } from "@douyinfe/semi-ui"; import ColorPicker from "../EditorSidePanel/ColorPicker"; @@ -179,6 +179,14 @@ export default function Note({ data, onPointerDown }) { const width = data.width ?? noteWidth; const MIN_NOTE_WIDTH = 120; + useEffect(() => { + const textarea = document.getElementById(`note_${data.id}`); + textarea.style.height = "0"; + textarea.style.height = textarea.scrollHeight + "px"; + const newHeight = textarea.scrollHeight + 42; + updateNote(data.id, { height: newHeight }); + }); + return ( e.isPrimary && setHovered(true)} @@ -506,4 +514,4 @@ export default function Note({ data, onPointerDown }) { ); -} +} \ No newline at end of file From e470a1325707528f969458d2be32299d1521f5d0 Mon Sep 17 00:00:00 2001 From: Red-Hide Date: Thu, 16 Oct 2025 18:37:49 +0200 Subject: [PATCH 2/3] Add missing dependency array Issue : drawdb-io#647 --- src/components/EditorCanvas/Note.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/EditorCanvas/Note.jsx b/src/components/EditorCanvas/Note.jsx index e975775e..992d2a60 100644 --- a/src/components/EditorCanvas/Note.jsx +++ b/src/components/EditorCanvas/Note.jsx @@ -185,7 +185,7 @@ export default function Note({ data, onPointerDown }) { textarea.style.height = textarea.scrollHeight + "px"; const newHeight = textarea.scrollHeight + 42; updateNote(data.id, { height: newHeight }); - }); + }, [data, updateNote]); return ( Date: Fri, 17 Oct 2025 09:56:38 +0200 Subject: [PATCH 3/3] Update src/components/EditorCanvas/Note.jsx Co-authored-by: 1ilit <1ilit@proton.me> --- src/components/EditorCanvas/Note.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/EditorCanvas/Note.jsx b/src/components/EditorCanvas/Note.jsx index 992d2a60..24341e61 100644 --- a/src/components/EditorCanvas/Note.jsx +++ b/src/components/EditorCanvas/Note.jsx @@ -185,7 +185,7 @@ export default function Note({ data, onPointerDown }) { textarea.style.height = textarea.scrollHeight + "px"; const newHeight = textarea.scrollHeight + 42; updateNote(data.id, { height: newHeight }); - }, [data, updateNote]); + }, [data.id, updateNote]); return (