Skip to content

Commit 0945167

Browse files
Copilotmikebarkmin
andcommitted
Fix null check in handleFieldChange
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
1 parent d00d21e commit 0945167

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

packages/learningmap/src/EditorPanel.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,14 @@ export const EditorPanel: React.FC<EditorPanelProps> = ({
160160
};
161161

162162
const handleFieldChange = (field: string, value: any) => {
163-
setLocalNode((prev: Node<NodeData> | null) => ({
164-
...prev!,
165-
data: { ...prev!.data, [field]: value },
166-
className: field === "color" ? value : prev!.className
167-
}));
163+
setLocalNode((prev: Node<NodeData> | null) => {
164+
if (!prev) return prev;
165+
return {
166+
...prev,
167+
data: { ...prev.data, [field]: value },
168+
className: field === "color" ? value : prev.className
169+
};
170+
});
168171
};
169172

170173
const handleResourceChange = (index: number, field: string, value: string) => {

0 commit comments

Comments
 (0)