mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Fix scrolling in textarea when adding context
This commit is contained in:
@@ -126,8 +126,16 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
const newCursorPosition = newValue.indexOf(" ", mentionIndex + insertValue.length) + 1
|
const newCursorPosition = newValue.indexOf(" ", mentionIndex + insertValue.length) + 1
|
||||||
setCursorPosition(newCursorPosition)
|
setCursorPosition(newCursorPosition)
|
||||||
setIntendedCursorPosition(newCursorPosition)
|
setIntendedCursorPosition(newCursorPosition)
|
||||||
|
// textAreaRef.current.focus()
|
||||||
|
|
||||||
|
// scroll to cursor
|
||||||
|
setTimeout(() => {
|
||||||
|
if (textAreaRef.current) {
|
||||||
|
textAreaRef.current.blur()
|
||||||
textAreaRef.current.focus()
|
textAreaRef.current.focus()
|
||||||
}
|
}
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[setInputValue, cursorPosition]
|
[setInputValue, cursorPosition]
|
||||||
)
|
)
|
||||||
@@ -311,6 +319,17 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
setCursorPosition(newCursorPosition)
|
setCursorPosition(newCursorPosition)
|
||||||
setIntendedCursorPosition(newCursorPosition)
|
setIntendedCursorPosition(newCursorPosition)
|
||||||
setShowContextMenu(false)
|
setShowContextMenu(false)
|
||||||
|
|
||||||
|
// Scroll to new cursor position
|
||||||
|
// https://stackoverflow.com/questions/29899364/how-do-you-scroll-to-the-position-of-the-cursor-in-a-textarea/40951875#40951875
|
||||||
|
setTimeout(() => {
|
||||||
|
if (textAreaRef.current) {
|
||||||
|
textAreaRef.current.blur()
|
||||||
|
textAreaRef.current.focus()
|
||||||
|
}
|
||||||
|
}, 0)
|
||||||
|
// NOTE: callbacks dont utilize return function to cleanup, but it's fine since this timeout immediately executes and will be cleaned up by the browser (no chance component unmounts before it executes)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
maxHeight: "200px",
|
maxHeight: "200px",
|
||||||
overflowY: "auto",
|
overflowY: "auto",
|
||||||
overflow: "hidden",
|
|
||||||
}}>
|
}}>
|
||||||
{/* Can't use virtuoso since it requires fixed height and menu height is dynamic based on # of items */}
|
{/* Can't use virtuoso since it requires fixed height and menu height is dynamic based on # of items */}
|
||||||
{filteredOptions.map((option, index) => (
|
{filteredOptions.map((option, index) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user