Skip to content

Commit 438088a

Browse files
authored
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
1 parent 19cc82f commit 438088a

4 files changed

Lines changed: 23 additions & 39 deletions

File tree

src/frontend/src/CustomNodes/GenericNode/components/NodeDescription/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ export default function NodeDescription({
143143
return (
144144
<div
145145
className={cn(
146-
!editNameDescription ? "overflow-auto" : "",
146+
!editNameDescription ? "overflow-auto" : "overflow-hidden",
147147
hasScroll ? "nowheel" : "",
148-
charLimit ? "px-2 pb-4" : "",
148+
charLimit ? "flex flex-col" : "",
149149
"w-full",
150150
)}
151151
>
@@ -155,7 +155,9 @@ export default function NodeDescription({
155155
maxLength={charLimit}
156156
className={cn(
157157
"nowheel w-full text-xs focus:border-primary focus:ring-0",
158-
stickyNote ? "p-0 pt-0.5 !text-mmd" : "px-2 py-0.5",
158+
stickyNote
159+
? "overflow-auto p-0 px-2 pt-0.5 !text-mmd"
160+
: "px-2 py-0.5",
159161
inputClassName,
160162
)}
161163
autoFocus
@@ -168,7 +170,7 @@ export default function NodeDescription({
168170
{charLimit && (nodeDescription?.length ?? 0) >= charLimit - 100 && (
169171
<div
170172
className={cn(
171-
"pt-1 text-left text-mmd",
173+
"pt-1 text-left !text-mmd",
172174
(nodeDescription?.length ?? 0) >= charLimit
173175
? "text-error"
174176
: "text-primary",

src/frontend/src/CustomNodes/GenericNode/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ function GenericNode({
554554
<div className="px-4 pb-3">
555555
<MemoizedNodeDescription
556556
description={data.node?.description}
557+
charLimit={1000}
557558
mdClassName={"dark:prose-invert"}
558559
nodeId={data.id}
559560
selected={selected}

src/frontend/src/CustomNodes/NoteNode/index.tsx

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ function NoteNode({
3232
(key) => key === data.node?.template.backgroundColor,
3333
) ?? Object.keys(COLOR_OPTIONS)[0];
3434
const nodeDiv = useRef<HTMLDivElement>(null);
35-
const [size, setSize] = useState({
36-
width: DEFAULT_WIDTH - NOTE_NODE_PADDING,
37-
height: DEFAULT_HEIGHT - NOTE_NODE_PADDING,
38-
});
3935
const [resizedNote, setResizedNote] = useState(false);
4036
const currentFlow = useFlowStore((state) => state.currentFlow);
4137
const setNode = useFlowStore((state) => state.setNode);
@@ -47,12 +43,12 @@ function NoteNode({
4743
);
4844

4945
const nodeDataWidth = useMemo(
50-
() => nodeData?.width ?? DEFAULT_WIDTH,
51-
[nodeData?.width],
46+
() => nodeData?.measured?.width ?? DEFAULT_WIDTH,
47+
[nodeData?.measured?.width],
5248
);
5349
const nodeDataHeight = useMemo(
54-
() => nodeData?.height ?? DEFAULT_HEIGHT,
55-
[nodeData?.height],
50+
() => nodeData?.measured?.height ?? DEFAULT_HEIGHT,
51+
[nodeData?.measured?.height],
5652
);
5753

5854
const dataId = useMemo(() => data.id, [data.id]);
@@ -64,10 +60,6 @@ function NoteNode({
6460
const debouncedResize = useMemo(
6561
() =>
6662
debounce((width: number, height: number) => {
67-
setSize({
68-
width: width - NOTE_NODE_PADDING,
69-
height: height - NOTE_NODE_PADDING,
70-
});
7163
setNode(data.id, (node) => {
7264
return {
7365
...node,
@@ -79,22 +71,6 @@ function NoteNode({
7971
[],
8072
);
8173

82-
useEffect(() => {
83-
if (nodeData && !resizedNote && nodeDataWidth > 0 && nodeDataHeight > 0) {
84-
setSize({
85-
width: nodeDataWidth - NOTE_NODE_PADDING,
86-
height: nodeDataHeight - NOTE_NODE_PADDING,
87-
});
88-
} else if (!nodeData && nodeDiv.current) {
89-
const currentWidth = nodeDiv.current.offsetWidth || DEFAULT_WIDTH;
90-
const currentHeight = nodeDiv.current.offsetHeight || DEFAULT_HEIGHT;
91-
setSize({
92-
width: Math.max(currentWidth, DEFAULT_WIDTH) - NOTE_NODE_PADDING,
93-
height: Math.max(currentHeight, DEFAULT_HEIGHT) - NOTE_NODE_PADDING,
94-
});
95-
}
96-
}, [nodeData, nodeDataWidth, nodeDataHeight, resizedNote]);
97-
9874
const [editNameDescription, set] = useAlternate(false);
9975

10076
const MemoNoteToolbarComponent = useMemo(
@@ -108,6 +84,8 @@ function NoteNode({
10884
),
10985
[data, bgColor, selected],
11086
);
87+
console.log(nodeData);
88+
console.log();
11189
return (
11290
<>
11391
<NodeResizer
@@ -133,8 +111,8 @@ function NoteNode({
133111
<div
134112
data-testid="note_node"
135113
style={{
136-
minWidth: Math.max(DEFAULT_WIDTH, NOTE_NODE_MIN_WIDTH),
137-
minHeight: Math.max(DEFAULT_HEIGHT, NOTE_NODE_MIN_HEIGHT),
114+
minWidth: nodeDataWidth,
115+
minHeight: nodeDataHeight,
138116
backgroundColor: COLOR_OPTIONS[bgColor] ?? "#00000000",
139117
}}
140118
ref={nodeDiv}
@@ -161,7 +139,7 @@ function NoteNode({
161139
>
162140
<NodeDescription
163141
inputClassName={cn(
164-
"border-0 ring-0 focus:ring-0 resize-none shadow-none rounded-sm h-full w-full",
142+
"border-0 ring-0 focus:ring-0 resize-none shadow-none rounded-sm h-full min-w-full",
165143
COLOR_OPTIONS[bgColor] === null
166144
? ""
167145
: "dark:!ring-background dark:text-background",
@@ -178,9 +156,10 @@ function NoteNode({
178156
selected={selected}
179157
description={dataDescription}
180158
emptyPlaceholder="Double-click to start typing or enter Markdown..."
181-
placeholderClassName={
182-
COLOR_OPTIONS[bgColor] === null ? "" : "dark:!text-background"
183-
}
159+
placeholderClassName={cn(
160+
COLOR_OPTIONS[bgColor] === null ? "" : "dark:!text-background",
161+
"px-2",
162+
)}
184163
editNameDescription={editNameDescription}
185164
setEditNameDescription={set}
186165
stickyNote

src/frontend/src/modals/templatesModal/components/TemplateContentComponent/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { track } from "@/customization/utils/analytics";
33
import useAddFlow from "@/hooks/flows/use-add-flow";
44
import useFlowsManagerStore from "@/stores/flowsManagerStore";
55
import Fuse from "fuse.js";
6+
import { SearchIcon } from "lucide-react";
67
import { useEffect, useMemo, useRef, useState } from "react";
78
import { useParams } from "react-router-dom";
89
import { ForwardedIconComponent } from "../../../../components/common/genericIconComponent";
@@ -83,11 +84,12 @@ export default function TemplateContentComponent({
8384
<Input
8485
type="search"
8586
placeholder="Search..."
87+
icon={"SearchIcon"}
8688
data-testid="search-input-template"
8789
value={searchQuery}
8890
onChange={(e) => setSearchQuery(e.target.value)}
8991
ref={searchInputRef}
90-
className="w-3/4 rounded-lg bg-background pl-8 lg:w-2/3"
92+
className="w-3/4 rounded-lg bg-background lg:w-2/3"
9193
/>
9294
</div>
9395
<div

0 commit comments

Comments
 (0)