Skip to content

Commit 5a08f97

Browse files
Garothhugelung
andauthored
RooCodeInc#2272 fix 'see more' not showing up (RooCodeInc#2390)
* RooCodeInc#2272 fix 'see more' not showing up * changeset & format --------- Co-authored-by: Andrei Edell <[email protected]>
1 parent 4ec85af commit 5a08f97

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

.changeset/eleven-shirts-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
Fix "See more" not showing up for tasks after task un-fold

webview-ui/src/components/chat/TaskHeader.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
5252
}
5353
}, [checkpointTrackerErrorMessage])
5454

55+
// Reset isTextExpanded when task is collapsed
56+
useEffect(() => {
57+
if (!isTaskExpanded) {
58+
setIsTextExpanded(false)
59+
}
60+
}, [isTaskExpanded])
61+
5562
/*
5663
When dealing with event listeners in React components that depend on state variables, we face a challenge. We want our listener to always use the most up-to-date version of a callback function that relies on current state, but we don't want to constantly add and remove event listeners as that function updates. This scenario often arises with resize listeners or other window events. Simply adding the listener in a useEffect with an empty dependency array risks using stale state, while including the callback in the dependencies can lead to unnecessary re-registrations of the listener. There are react hook libraries that provide a elegant solution to this problem by utilizing the useRef hook to maintain a reference to the latest callback function without triggering re-renders or effect re-runs. This approach ensures that our event listener always has access to the most current state while minimizing performance overhead and potential memory leaks from multiple listener registrations.
5764
Sources
@@ -95,17 +102,19 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
95102

96103
useEffect(() => {
97104
if (isTaskExpanded && textRef.current && textContainerRef.current) {
98-
let textContainerHeight = textContainerRef.current.clientHeight
99-
if (!textContainerHeight) {
100-
textContainerHeight = textContainerRef.current.getBoundingClientRect().height
101-
}
102-
const isOverflowing = textRef.current.scrollHeight > textContainerHeight
105+
// Use requestAnimationFrame to ensure DOM is fully updated
106+
requestAnimationFrame(() => {
107+
// Check if refs are still valid
108+
if (textRef.current && textContainerRef.current) {
109+
let textContainerHeight = textContainerRef.current.clientHeight
110+
if (!textContainerHeight) {
111+
textContainerHeight = textContainerRef.current.getBoundingClientRect().height
112+
}
113+
const isOverflowing = textRef.current.scrollHeight > textContainerHeight
103114

104-
// necessary to show see more button again if user resizes window to expand and then back to collapse
105-
if (!isOverflowing) {
106-
setIsTextExpanded(false)
107-
}
108-
setShowSeeMore(isOverflowing)
115+
setShowSeeMore(isOverflowing)
116+
}
117+
})
109118
}
110119
}, [task.text, windowWidth, isTaskExpanded])
111120

0 commit comments

Comments
 (0)