Skip to content

Commit

Permalink
file selection
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-schabel committed Jan 17, 2025
1 parent 4c8b365 commit b54a7ce
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions packages/client/src/components/projects/file-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,15 @@ export const FilePanel = forwardRef<FilePanelRef, FilePanelProps>(({
// In your file-panel.tsx (within FilePanel component):
const selectFileFromAutocomplete = (file: ProjectFile) => {
handleSetSelectedFiles((prev) => {
if (prev.includes(file.id)) return prev
// Toggle selection - remove if already selected, add if not
if (prev.includes(file.id)) {
return prev.filter(id => id !== file.id)
}
return [...prev, file.id]
})
// If you want to open the viewer automatically:
// openFileViewer(file)

// Reset the highlighted index but don't close autocomplete
setAutocompleteIndex(-1)

// Keep it open
// setShowAutocomplete(false) // REMOVE this line

// Keep the input focused
// Keep the current index and autocomplete state
setShowAutocomplete(true)
searchInputRef.current?.focus()
}

Expand Down Expand Up @@ -328,19 +324,23 @@ export const FilePanel = forwardRef<FilePanelRef, FilePanelProps>(({
</li>
{suggestions.map((file, index) => {
const isHighlighted = index === autocompleteIndex
const isSelected = selectedFiles.includes(file.id)
return (
<li
key={file.id}
className={`px-2 py-1 cursor-pointer ${isHighlighted ? 'bg-gray-200' : ''
}`}
className={`px-2 py-1 cursor-pointer flex items-center justify-between ${
isHighlighted ? 'bg-gray-200' : ''
}`}
onMouseDown={(e) => {
// onMouseDown instead of onClick so we don't blur the input
e.preventDefault()
selectFileFromAutocomplete(file)
}}
onMouseEnter={() => setAutocompleteIndex(index)}
>
{file.path}
<span>{file.path}</span>
{isSelected && (
<Badge variant="secondary" className="ml-2">Selected</Badge>
)}
</li>
)
})}
Expand Down

0 comments on commit b54a7ce

Please sign in to comment.