diff --git a/src/components/map/MapNotes.js b/src/components/map/MapNotes.js index 4efacf9..1f31893 100644 --- a/src/components/map/MapNotes.js +++ b/src/components/map/MapNotes.js @@ -69,13 +69,15 @@ function MapNotes({ } function handleBrushMove() { - const brushPosition = getBrushPosition(); - setNoteData((prev) => ({ - ...prev, - x: brushPosition.x, - y: brushPosition.y, - })); - setIsBrushDown(true); + if (noteData) { + const brushPosition = getBrushPosition(); + setNoteData((prev) => ({ + ...prev, + x: brushPosition.x, + y: brushPosition.y, + })); + setIsBrushDown(true); + } } function handleBrushUp() { diff --git a/src/components/note/Note.js b/src/components/note/Note.js index 884757e..d743dfa 100644 --- a/src/components/note/Note.js +++ b/src/components/note/Note.js @@ -104,17 +104,22 @@ function Note({ (_, i) => i + Math.ceil(noteHeight / 10) ); - return sizes.reduce((prev, curr) => { - text.fontSize(curr); - const width = text.getTextWidth() + notePadding * 2; - if (width < noteWidth) { - return curr; - } else { - return prev; - } - }); + if (sizes.length > 0) { + const size = sizes.reduce((prev, curr) => { + text.fontSize(curr); + const width = text.getTextWidth() + notePadding * 2; + if (width < noteWidth) { + return curr; + } else { + return prev; + } + }); + + setFontSize(size); + } } - setFontSize(findFontSize()); + + findFontSize(); }, [note, noteWidth, noteHeight, notePadding]); const textRef = useRef();