fix(webview-ui): preserve edit content after virtualization and pre-scroll bubble into view before entering edit mode

This commit is contained in:
Roo Code 2025-10-18 23:29:41 +00:00
parent 03ac80fb17
commit 15932f901d

View file

@ -185,6 +185,15 @@ export const ChatRowContent = ({
// No need to notify the backend
}, [message.ts, message.text, message.images, mode, onStartEditing])
// Ensure edit fields are initialized when entering edit mode (including after virtualization re-mounts)
useEffect(() => {
if (!isEditing) return
// Only initialize if user hasn't typed yet / images not selected
setEditedContent((prev) => (prev !== "" ? prev : message.text || ""))
setEditImages((prev) => (prev.length > 0 ? prev : message.images || []))
setEditMode((prev) => prev || mode || "code")
}, [isEditing, message.text, message.images, mode])
// Ensure the edit textarea is focused and scrolled into view when entering edit mode.
// Uses a short delay and a few animation frames to allow virtualization reflow before scrolling.
useEffect(() => {