Fix mobile input prompt command selection (#148)

* fix mobile selection in suggestion dropdowns

* handle mobile keyboard viewport
This commit is contained in:
Chris Scott authored and GitHub committed 2026-02-27 17:35:01 -05:00
1 parent f368a2fa62
commit a3237d7f7f
6 files changed
+61 -6

No files matched your search

@@ -50,11 +50,16 @@ export function FileSuggestions({
return (
<div
ref={listRef}
className="absolute bottom-full left-0 right-0 mb-2 z-50 bg-background border border-border rounded-lg shadow-xl max-h-[30vh] md:max-h-[40vh] lg:max-h-[50vh] overflow-y-auto"
className="absolute bottom-full left-0 right-0 mb-2 z-50 bg-background border border-border rounded-lg shadow-xl max-h-48 md:max-h-[40vh] lg:max-h-[50vh] overflow-y-auto"
>
{files.map((file, idx) => (
<button
key={file}
onMouseDown={(e) => e.preventDefault()}
onTouchEnd={(e) => {
e.preventDefault()
onSelect(file)
}}
onClick={() => onSelect(file)}
className={`w-full px-3 py-2 text-left transition-colors ${
idx === selectedIndex
@@ -58,11 +58,16 @@ export function MentionSuggestions({
return (
<div
ref={listRef}
className="absolute bottom-full left-0 right-0 mb-2 z-50 bg-background border border-border rounded-lg shadow-xl max-h-[30vh] md:max-h-[40vh] lg:max-h-[50vh] overflow-y-auto"
className="absolute bottom-full left-0 right-0 mb-2 z-50 bg-background border border-border rounded-lg shadow-xl max-h-48 md:max-h-[40vh] lg:max-h-[50vh] overflow-y-auto"
>
{items.map((item, idx) => (
<button
key={`${item.type}-${item.value}`}
onMouseDown={(e) => e.preventDefault()}
onTouchEnd={(e) => {
e.preventDefault()
onSelect(item)
}}
onClick={() => onSelect(item)}
className={`w-full px-3 py-2 text-left transition-colors flex items-start gap-2 ${
idx === selectedIndex
@@ -284,6 +284,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
if (textareaRef.current) {
textareaRef.current.focus()
textareaRef.current.setSelectionRange(cleanedTemplate.length, cleanedTemplate.length)
textareaRef.current.scrollTop = textareaRef.current.scrollHeight
}
}, 0)
} else {
@@ -302,6 +303,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
const newCursorPos = beforeCommand.length + command.name.length + 2
textareaRef.current.focus()
textareaRef.current.setSelectionRange(newCursorPos, newCursorPos)
textareaRef.current.scrollTop = textareaRef.current.scrollHeight
}
}, 0)
}
@@ -324,6 +326,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
const newCursorPos = beforeMention.length + item.value.length + 2
textareaRef.current.focus()
textareaRef.current.setSelectionRange(newCursorPos, newCursorPos)
textareaRef.current.scrollTop = textareaRef.current.scrollHeight
}
}, 0)
} else {
@@ -351,6 +354,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
const newCursorPos = beforeMention.length + filename.length + 2
textareaRef.current.focus()
textareaRef.current.setSelectionRange(newCursorPos, newCursorPos)
textareaRef.current.scrollTop = textareaRef.current.scrollHeight
}
}, 0)
}