From 823eabe1dbbb5601353422e0d3321c2dd494b4a6 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Fri, 14 Mar 2025 22:05:17 +0000 Subject: [PATCH] Properly handle null tree node name and icon --- apps/client/src/features/editor/title-editor.tsx | 2 +- apps/client/src/features/websocket/use-tree-socket.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/client/src/features/editor/title-editor.tsx b/apps/client/src/features/editor/title-editor.tsx index d2cc4783..9cb17aa0 100644 --- a/apps/client/src/features/editor/title-editor.tsx +++ b/apps/client/src/features/editor/title-editor.tsx @@ -67,11 +67,11 @@ export function TitleEditor({ if (editor) { // @ts-ignore setTitleEditor(editor); + setActivePageId(pageId); } }, onUpdate({ editor }) { debounceUpdate(); - setActivePageId(pageId); }, editable: editable, content: title, diff --git a/apps/client/src/features/websocket/use-tree-socket.ts b/apps/client/src/features/websocket/use-tree-socket.ts index b203ee1c..df160ec8 100644 --- a/apps/client/src/features/websocket/use-tree-socket.ts +++ b/apps/client/src/features/websocket/use-tree-socket.ts @@ -23,14 +23,14 @@ export const useTreeSocket = () => { const initialData = initialTreeData.current; const treeApi = new SimpleTree(initialData); - if (treeApi.find(event.id)) { - if (event.payload?.title) { + if (treeApi.find(event?.id)) { + if (event.payload?.title !== undefined) { treeApi.update({ id: event.id, changes: { name: event.payload.title }, }); + setTreeData(treeApi.data); } - setTreeData(treeApi.data); } }; @@ -49,13 +49,13 @@ export const useTreeSocket = () => { case "updateOne": if (event.entity[0] === "pages") { if (treeApi.find(event.id)) { - if (event.payload?.title) { + if (event.payload?.title !== undefined) { treeApi.update({ id: event.id, changes: { name: event.payload.title }, }); } - if (event.payload?.icon) { + if (event.payload?.icon !== undefined) { treeApi.update({ id: event.id, changes: { icon: event.payload.icon },