Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Update note list display on desktop

fzaninottof07d6967904e
diff --git a/src/components/atomic-crm/notes/Note.tsx b/src/components/atomic-crm/notes/Note.tsx
index 2e3ac09e..ff2796ee 100644
--- a/src/components/atomic-crm/notes/Note.tsx
+++ b/src/components/atomic-crm/notes/Note.tsx
@@ -32,10 +32,11 @@ import { useGetSalesName } from "../sales/useGetSalesName";
export const Note = ({
showStatus,
note,
+ isCompact,
}: {
showStatus?: boolean;
note: DealNote | ContactNote;
- isLast: boolean;
+ isCompact?: boolean;
}) => {
const [isHover, setHover] = useState(false);
const [isEditing, setEditing] = useState(false);
@@ -51,13 +52,14 @@ export const Note = ({
enabled: !isCurrentUser,
});
- // Detect if content is truncated
+ const isCollapsedCompact = isCompact && !isExpanded;
+
useEffect(() => {
const el = contentRef.current;
- if (el) {
+ if (el && !isExpanded) {
setTruncated(el.scrollHeight > el.clientHeight);
}
- }, [note.text]);
+ }, [note.text, isCompact, isExpanded]);
const [update, { isPending }] = useUpdate();
@@ -187,18 +189,20 @@ export const Note = ({
</Form>
) : (
<div className="pt-2 text-sm max-w-150">
- {note.text && (
- <div
- ref={contentRef}
- className={cn(
- "overflow-hidden transition-[max-height] duration-300 ease-in-out",
- isExpanded ? "max-h-[5000px]" : "max-h-46",
- )}
- >
- <Markdown>{note.text}</Markdown>
- </div>
- )}
- {isTruncated && (
+ {note.text &&
+ (isCollapsedCompact ? (
+ <p ref={contentRef} className="line-clamp-2">
+ {note.text.replace(/\s+/g, " ").trim()}
+ </p>
+ ) : (
+ <div
+ ref={contentRef}
+ className={cn("overflow-hidden", !isExpanded && "max-h-[70vh]")}
+ >
+ <Markdown>{note.text}</Markdown>
+ </div>
+ ))}
+ {(isTruncated || (isCollapsedCompact && note.attachments)) && (
<button
onClick={(e) => {
e.stopPropagation();
@@ -212,7 +216,9 @@ export const Note = ({
</button>
)}
- {note.attachments && <NoteAttachments note={note} />}
+ {note.attachments && !isCollapsedCompact && (
+ <NoteAttachments note={note} />
+ )}
</div>
)}
</div>
diff --git a/src/components/atomic-crm/notes/NotesIterator.tsx b/src/components/atomic-crm/notes/NotesIterator.tsx
index a5647d68..90c64697 100644
--- a/src/components/atomic-crm/notes/NotesIterator.tsx
+++ b/src/components/atomic-crm/notes/NotesIterator.tsx
@@ -24,11 +24,7 @@ export const NotesIterator = ({
<div className="mt-4 space-y-4">
{data.map((note, index) => (
<Fragment key={note.id}>
- <Note
- note={note}
- isLast={index === data.length - 1}
- showStatus={showStatus}
- />
+ <Note note={note} isCompact={index > 0} showStatus={showStatus} />
{index < data.length - 1 && <Separator />}
</Fragment>
))}