From 438088ac4d5414880b7ed33ccf8f69060452e5fc Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:46:43 -0300 Subject: [PATCH] fix: make notes size consistent when editing, add char limit to description, fix design of search bar on templates modal (#8679) * Fixed template content component search bar * Fixed size of notenode not applying to some instances * Fixed generic node description not having char limit --- .../components/NodeDescription/index.tsx | 10 ++-- .../src/CustomNodes/GenericNode/index.tsx | 1 + .../src/CustomNodes/NoteNode/index.tsx | 47 +++++-------------- .../TemplateContentComponent/index.tsx | 4 +- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/NodeDescription/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/NodeDescription/index.tsx index 3142d7064..965cb05b0 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/NodeDescription/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/NodeDescription/index.tsx @@ -143,9 +143,9 @@ export default function NodeDescription({ return (
@@ -155,7 +155,9 @@ export default function NodeDescription({ maxLength={charLimit} className={cn( "nowheel w-full text-xs focus:border-primary focus:ring-0", - stickyNote ? "p-0 pt-0.5 !text-mmd" : "px-2 py-0.5", + stickyNote + ? "overflow-auto p-0 px-2 pt-0.5 !text-mmd" + : "px-2 py-0.5", inputClassName, )} autoFocus @@ -168,7 +170,7 @@ export default function NodeDescription({ {charLimit && (nodeDescription?.length ?? 0) >= charLimit - 100 && (
= charLimit ? "text-error" : "text-primary", diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index d6406ae3b..dae1f3fde 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -554,6 +554,7 @@ function GenericNode({
key === data.node?.template.backgroundColor, ) ?? Object.keys(COLOR_OPTIONS)[0]; const nodeDiv = useRef(null); - const [size, setSize] = useState({ - width: DEFAULT_WIDTH - NOTE_NODE_PADDING, - height: DEFAULT_HEIGHT - NOTE_NODE_PADDING, - }); const [resizedNote, setResizedNote] = useState(false); const currentFlow = useFlowStore((state) => state.currentFlow); const setNode = useFlowStore((state) => state.setNode); @@ -47,12 +43,12 @@ function NoteNode({ ); const nodeDataWidth = useMemo( - () => nodeData?.width ?? DEFAULT_WIDTH, - [nodeData?.width], + () => nodeData?.measured?.width ?? DEFAULT_WIDTH, + [nodeData?.measured?.width], ); const nodeDataHeight = useMemo( - () => nodeData?.height ?? DEFAULT_HEIGHT, - [nodeData?.height], + () => nodeData?.measured?.height ?? DEFAULT_HEIGHT, + [nodeData?.measured?.height], ); const dataId = useMemo(() => data.id, [data.id]); @@ -64,10 +60,6 @@ function NoteNode({ const debouncedResize = useMemo( () => debounce((width: number, height: number) => { - setSize({ - width: width - NOTE_NODE_PADDING, - height: height - NOTE_NODE_PADDING, - }); setNode(data.id, (node) => { return { ...node, @@ -79,22 +71,6 @@ function NoteNode({ [], ); - useEffect(() => { - if (nodeData && !resizedNote && nodeDataWidth > 0 && nodeDataHeight > 0) { - setSize({ - width: nodeDataWidth - NOTE_NODE_PADDING, - height: nodeDataHeight - NOTE_NODE_PADDING, - }); - } else if (!nodeData && nodeDiv.current) { - const currentWidth = nodeDiv.current.offsetWidth || DEFAULT_WIDTH; - const currentHeight = nodeDiv.current.offsetHeight || DEFAULT_HEIGHT; - setSize({ - width: Math.max(currentWidth, DEFAULT_WIDTH) - NOTE_NODE_PADDING, - height: Math.max(currentHeight, DEFAULT_HEIGHT) - NOTE_NODE_PADDING, - }); - } - }, [nodeData, nodeDataWidth, nodeDataHeight, resizedNote]); - const [editNameDescription, set] = useAlternate(false); const MemoNoteToolbarComponent = useMemo( @@ -108,6 +84,8 @@ function NoteNode({ ), [data, bgColor, selected], ); + console.log(nodeData); + console.log(); return ( <> setSearchQuery(e.target.value)} ref={searchInputRef} - className="w-3/4 rounded-lg bg-background pl-8 lg:w-2/3" + className="w-3/4 rounded-lg bg-background lg:w-2/3" />