From 8343fe63cb7ea1a197d1db760c67cf3514cc39b9 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Sat, 14 Jun 2025 02:02:36 +0530 Subject: [PATCH 1/2] (feat:bubble) collapsable questions --- .../src/conversation/ConversationBubble.tsx | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 1bf8dafe..422e0de6 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -1,6 +1,6 @@ import 'katex/dist/katex.min.css'; -import { forwardRef, Fragment, useRef, useState } from 'react'; +import { forwardRef, Fragment, useRef, useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import ReactMarkdown from 'react-markdown'; import { useSelector } from 'react-redux'; @@ -90,14 +90,24 @@ const ConversationBubble = forwardRef< const [isDislikeHovered, setIsDislikeHovered] = useState(false); const [isQuestionHovered, setIsQuestionHovered] = useState(false); const [editInputBox, setEditInputBox] = useState(''); - + const messageRef = useRef(null); + const [shouldShowToggle, setShouldShowToggle] = useState(false); const [isLikeClicked, setIsLikeClicked] = useState(false); const [isDislikeClicked, setIsDislikeClicked] = useState(false); const [activeTooltip, setActiveTooltip] = useState(null); const [isSidebarOpen, setIsSidebarOpen] = useState(false); const editableQueryRef = useRef(null); + const [isQuestionCollapsed, setIsQuestionCollapsed] = useState(true); useOutsideAlerter(editableQueryRef, () => setIsEditClicked(false), [], true); + + useEffect(() => { + if (messageRef.current) { + const height = messageRef.current.scrollHeight; + setShouldShowToggle(height > 84); + } + }, [message]); + const handleEditClick = () => { setIsEditClicked(false); handleUpdatedQuestionSubmission?.(editInputBox, true, questionNumber); @@ -146,15 +156,35 @@ const ConversationBubble = forwardRef< /> {!isEditClicked && ( <> -
+
- {message} +
+ {message} +
+ {shouldShowToggle && ( + + )}
+ )}
- {shouldShowToggle && ( - - )}