Skip to content

Commit

Permalink
Merge pull request #68 from wizelineacademy/web/chore/frontend/conver…
Browse files Browse the repository at this point in the history
…sation-sidebar-style

fix: 🐛 Remove unwanted resetting of conversation titles
  • Loading branch information
emiof authored Nov 8, 2023
2 parents 8518abd + 1642e26 commit 73df0f2
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface ConversationCardProps {

export function ConversationCard({userTags, conversation, conversationsDispatch, isSelected, onClick,}: ConversationCardProps): JSX.Element {
const [title, setTitle] = useState<string>(conversation.title);
const [unmodifiedTitle, setUnmodifiedTitle] = useState<string>(conversation.title)
const [conversationTags, setConversationTags] = useState<Set<number>>(buildTagSet(conversation));
const [editingTitle, setEditingTitle] = useState<boolean>(false);
const [tagMenuModalIsOpen, setTagMenuModalIsOpen] = useState<boolean>(false);
Expand All @@ -35,12 +34,11 @@ export function ConversationCard({userTags, conversation, conversationsDispatch,
return () => {
document.removeEventListener("click", handleOutsideClick);
};

}, []);
});

const handleOutsideClick: (e: MouseEvent) => void = (e) => {
if (cardContainerRef.current && !cardContainerRef.current.contains(e.target as Node)){
setTitle(unmodifiedTitle);
setTitle(conversation.title);
setEditingTitle(false);
}
};
Expand All @@ -56,7 +54,7 @@ export function ConversationCard({userTags, conversation, conversationsDispatch,
};

const handleTitleCancelPress: () => void = () => {
setTitle(unmodifiedTitle)
setTitle(conversation.title)
setEditingTitle(false)
}

Expand Down Expand Up @@ -96,7 +94,6 @@ export function ConversationCard({userTags, conversation, conversationsDispatch,
conversationId: conversation.id,
title: updatedConversation.title,
});
setUnmodifiedTitle(updatedConversation.title as string)
setEditingTitle(false);
toast.success("Conversation title updated.");
})
Expand Down Expand Up @@ -151,9 +148,9 @@ export function ConversationCard({userTags, conversation, conversationsDispatch,
}

const titleWhenNotEditing: JSX.Element = (
<p className="text-xs text-white whitespace-nowrap overflow-scroll">
{title}
</p>
<div className="overflow-scroll scrollbar-hide">
<p className="text-xs text-white whitespace-nowrap">{title}</p>
</div>
);

const titleWhenEditing: JSX.Element = (
Expand Down

0 comments on commit 73df0f2

Please sign in to comment.