mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Fix command and file suggestions rendering position on mobile and desktop
This commit is contained in:
1 parent
6f88946aa9
commit
8665a4d0bb
3 files changed
+10
-48
No files matched your search
@@ -10,7 +10,6 @@ interface CommandSuggestionsProps {
|
||||
commands: CommandType[]
|
||||
onSelect: (command: CommandType) => void
|
||||
onClose: () => void
|
||||
position: { bottom: number; left: number; width: number }
|
||||
selectedIndex?: number
|
||||
}
|
||||
|
||||
@@ -19,7 +18,6 @@ export function CommandSuggestions({
|
||||
query,
|
||||
commands,
|
||||
onSelect,
|
||||
position,
|
||||
selectedIndex = 0
|
||||
}: CommandSuggestionsProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
@@ -50,12 +48,7 @@ export function CommandSuggestions({
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="fixed z-50 bg-[#1a1a1a] border border-[#333] rounded-lg shadow-lg max-h-64 overflow-y-auto"
|
||||
style={{
|
||||
bottom: `${position.bottom}px`, // Position from bottom
|
||||
left: `${position.left}px`,
|
||||
width: `${position.width}px`
|
||||
}}
|
||||
className="absolute bottom-full left-0 right-0 mb-2 z-50 bg-background border border-border rounded-lg shadow-lg max-h-64 overflow-y-auto"
|
||||
>
|
||||
<div className="p-1">
|
||||
{filteredCommands.map((command, index) => {
|
||||
@@ -68,17 +61,17 @@ export function CommandSuggestions({
|
||||
data-selected={isSelected}
|
||||
className={`px-3 py-2 cursor-pointer rounded-md transition-colors flex items-center gap-2 ${
|
||||
isSelected
|
||||
? 'bg-blue-600/20 text-white'
|
||||
: 'hover:bg-[#2a2a2a] text-zinc-300'
|
||||
? 'bg-primary/20 text-foreground'
|
||||
: 'hover:bg-muted text-muted-foreground'
|
||||
}`}
|
||||
onClick={() => onSelect(command)}
|
||||
|
||||
>
|
||||
<Command className="h-4 w-4 text-zinc-400 flex-shrink-0" />
|
||||
<Command className="h-4 w-4 text-muted-foreground flex-shrink-0" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="font-medium text-sm truncate">{displayName}</div>
|
||||
{command.description && (
|
||||
<div className="text-xs text-zinc-500 truncate">{command.description}</div>
|
||||
<div className="text-xs text-muted-foreground truncate">{command.description}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,7 +79,7 @@ export function CommandSuggestions({
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="px-3 py-2 border-t border-[#333] text-xs text-zinc-500">
|
||||
<div className="px-3 py-2 border-t border-border text-xs text-muted-foreground">
|
||||
<div className="flex items-center gap-4">
|
||||
<span>↑↓ Navigate</span>
|
||||
<span>↵ Select</span>
|
||||
|
||||
@@ -2,11 +2,9 @@ import { useEffect, useRef } from 'react'
|
||||
|
||||
interface FileSuggestionsProps {
|
||||
isOpen: boolean
|
||||
query: string
|
||||
files: string[]
|
||||
onSelect: (file: string) => void
|
||||
onClose: () => void
|
||||
position: { bottom: number, left: number, width: number }
|
||||
selectedIndex?: number
|
||||
}
|
||||
|
||||
@@ -15,7 +13,6 @@ export function FileSuggestions({
|
||||
files,
|
||||
onSelect,
|
||||
onClose,
|
||||
position,
|
||||
selectedIndex = 0
|
||||
}: FileSuggestionsProps) {
|
||||
const listRef = useRef<HTMLDivElement>(null)
|
||||
@@ -53,12 +50,7 @@ export function FileSuggestions({
|
||||
return (
|
||||
<div
|
||||
ref={listRef}
|
||||
className="fixed bg-zinc-900 border border-zinc-700 rounded-lg shadow-xl z-50 max-h-64 overflow-y-auto"
|
||||
style={{
|
||||
bottom: `${position.bottom}px`,
|
||||
left: `${position.left}px`,
|
||||
width: `${position.width}px`
|
||||
}}
|
||||
className="absolute bottom-full left-0 right-0 mb-2 z-50 bg-background border border-border rounded-lg shadow-xl max-h-64 overflow-y-auto"
|
||||
>
|
||||
{files.map((file, idx) => (
|
||||
<button
|
||||
@@ -66,8 +58,8 @@ export function FileSuggestions({
|
||||
onClick={() => onSelect(file)}
|
||||
className={`w-full px-3 py-2 text-left transition-colors ${
|
||||
idx === selectedIndex
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'hover:bg-zinc-800 text-zinc-100'
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: 'hover:bg-muted text-foreground'
|
||||
}`}
|
||||
>
|
||||
<div className="font-mono text-sm font-medium">
|
||||
|
||||
@@ -51,11 +51,9 @@ export function PromptInput({
|
||||
const [isBashMode, setIsBashMode] = useState(false)
|
||||
const [showSuggestions, setShowSuggestions] = useState(false)
|
||||
const [suggestionQuery, setSuggestionQuery] = useState('')
|
||||
const [suggestionPosition, setSuggestionPosition] = useState({ bottom: 0, left: 0, width: 0 })
|
||||
const [attachedFiles, setAttachedFiles] = useState(new Map<string, FileInfo>())
|
||||
const [showFileSuggestions, setShowFileSuggestions] = useState(false)
|
||||
const [fileQuery, setFileQuery] = useState('')
|
||||
const [fileSuggestionPosition, setFileSuggestionPosition] = useState({ bottom: 0, left: 0, width: 0 })
|
||||
const [mentionRange, setMentionRange] = useState<{ start: number, end: number } | null>(null)
|
||||
const [selectedFileIndex, setSelectedFileIndex] = useState(0)
|
||||
const [selectedCommandIndex, setSelectedCommandIndex] = useState(0)
|
||||
@@ -335,15 +333,6 @@ export function PromptInput({
|
||||
setMentionRange({ start: mentionTrigger.start, end: mentionTrigger.end })
|
||||
setShowFileSuggestions(true)
|
||||
setSelectedFileIndex(0)
|
||||
|
||||
if (textareaRef.current) {
|
||||
const rect = textareaRef.current.getBoundingClientRect()
|
||||
setFileSuggestionPosition({
|
||||
bottom: window.innerHeight - rect.top + window.scrollY + 4,
|
||||
left: rect.left + window.scrollX,
|
||||
width: rect.width
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const commandMatch = value.slice(0, cursorPosition).match(/(^|\s)\/([a-zA-Z0-9_-]*)$/)
|
||||
|
||||
@@ -352,15 +341,6 @@ export function PromptInput({
|
||||
setSuggestionQuery(query)
|
||||
setShowSuggestions(true)
|
||||
setSelectedCommandIndex(0)
|
||||
|
||||
if (textareaRef.current) {
|
||||
const rect = textareaRef.current.getBoundingClientRect()
|
||||
setSuggestionPosition({
|
||||
bottom: window.innerHeight - rect.top + window.scrollY + 4,
|
||||
left: rect.left + window.scrollX,
|
||||
width: rect.width
|
||||
})
|
||||
}
|
||||
} else {
|
||||
setShowSuggestions(false)
|
||||
setSuggestionQuery('')
|
||||
@@ -426,7 +406,7 @@ export function PromptInput({
|
||||
|
||||
|
||||
return (
|
||||
<div className="backdrop-blur-md bg-background opacity-95 border border-border rounded-xl p-2 md:p-3 mx-2 md:mx-4 mb-2 md:mb-5 w-[90%] md:max-w-4xl">
|
||||
<div className="relative backdrop-blur-md bg-background opacity-95 border border-border rounded-xl p-2 md:p-3 mx-2 md:mx-4 mb-2 md:mb-5 w-[90%] md:max-w-4xl">
|
||||
|
||||
|
||||
<textarea
|
||||
@@ -526,13 +506,11 @@ export function PromptInput({
|
||||
setShowSuggestions(false)
|
||||
setSuggestionQuery('')
|
||||
}}
|
||||
position={suggestionPosition}
|
||||
selectedIndex={selectedCommandIndex}
|
||||
/>
|
||||
|
||||
<FileSuggestions
|
||||
isOpen={showFileSuggestions}
|
||||
query={fileQuery}
|
||||
files={searchResults}
|
||||
onSelect={handleFileSelect}
|
||||
onClose={() => {
|
||||
@@ -540,7 +518,6 @@ export function PromptInput({
|
||||
setFileQuery('')
|
||||
setMentionRange(null)
|
||||
}}
|
||||
position={fileSuggestionPosition}
|
||||
selectedIndex={selectedFileIndex}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user