Select top result by default

This commit is contained in:
Saoud Rizwan
2024-09-16 18:41:40 -04:00
parent 5974679aaf
commit b9871310a4

View File

@@ -206,8 +206,13 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
setShowContextMenu(showMenu) setShowContextMenu(showMenu)
if (showMenu) { if (showMenu) {
const lastAtIndex = newValue.lastIndexOf("@", newCursorPosition - 1) const lastAtIndex = newValue.lastIndexOf("@", newCursorPosition - 1)
setSearchQuery(newValue.slice(lastAtIndex + 1, newCursorPosition)) const query = newValue.slice(lastAtIndex + 1, newCursorPosition)
setSelectedMenuIndex(2) // Set to "File" option by default setSearchQuery(query)
if (query.length > 0) {
setSelectedMenuIndex(0)
} else {
setSelectedMenuIndex(2) // Set to "File" option by default
}
} else { } else {
setSearchQuery("") setSearchQuery("")
setSelectedMenuIndex(-1) setSelectedMenuIndex(-1)