@@ -78,10 +78,15 @@ export default function Note({ data, onPointerDown }) {
7878
7979 const handleChange = ( e ) => {
8080 const textarea = document . getElementById ( `note_${ data . id } ` ) ;
81+ if ( ! textarea ) return ;
8182 textarea . style . height = "0" ;
8283 textarea . style . height = textarea . scrollHeight + "px" ;
8384 const newHeight = textarea . scrollHeight + 42 ;
84- updateNote ( data . id , { content : e . target . value , height : newHeight } ) ;
85+ const updates = { content : e . target . value } ;
86+ if ( newHeight !== data . height ) {
87+ updates . height = newHeight ;
88+ }
89+ updateNote ( data . id , updates ) ;
8590 } ;
8691
8792 const handleBlur = ( e ) => {
@@ -181,11 +186,17 @@ export default function Note({ data, onPointerDown }) {
181186
182187 useEffect ( ( ) => {
183188 const textarea = document . getElementById ( `note_${ data . id } ` ) ;
189+ if ( ! textarea ) return ;
190+
184191 textarea . style . height = "0" ;
185- textarea . style . height = textarea . scrollHeight + "px" ;
186- const newHeight = textarea . scrollHeight + 42 ;
192+ const scrollHeight = textarea . scrollHeight ;
193+ textarea . style . height = scrollHeight + "px" ;
194+ const newHeight = scrollHeight + 42 ;
195+
196+ if ( newHeight === data . height ) return ;
197+
187198 updateNote ( data . id , { height : newHeight } ) ;
188- } , [ data . id , updateNote ] ) ;
199+ } , [ data . id , data . height , updateNote ] ) ;
189200
190201 return (
191202 < g
@@ -339,7 +350,10 @@ export default function Note({ data, onPointerDown }) {
339350 onPointerMove = { ( e ) => {
340351 if ( ! resizing ) return ;
341352 const delta = e . movementX / ( transform ?. zoom || 1 ) ;
342- const next = Math . max ( MIN_NOTE_WIDTH , ( data . width ?? noteWidth ) + delta ) ;
353+ const next = Math . max (
354+ MIN_NOTE_WIDTH ,
355+ ( data . width ?? noteWidth ) + delta ,
356+ ) ;
343357 if ( next !== data . width ) {
344358 updateNote ( data . id , { width : next } ) ;
345359 }
@@ -514,4 +528,4 @@ export default function Note({ data, onPointerDown }) {
514528 </ foreignObject >
515529 </ g >
516530 ) ;
517- }
531+ }
0 commit comments