@@ -123,58 +123,54 @@ export const FileTreeFolder = ({
123123 children,
124124 ...props
125125} : FileTreeFolderProps ) => {
126- const { expandedPaths, togglePath, selectedPath , onSelect } =
126+ const { expandedPaths, togglePath } =
127127 useContext ( FileTreeContext ) ;
128128 const isExpanded = expandedPaths . has ( path ) ;
129- const isSelected = selectedPath === path ;
130129
131- const handleOpenChange = useCallback ( ( ) => {
130+ const handleToggle = useCallback ( ( ) => {
132131 togglePath ( path ) ;
133132 } , [ togglePath , path ] ) ;
134133
135- const handleSelect = useCallback ( ( ) => {
136- onSelect ?.( path ) ;
137- } , [ onSelect , path ] ) ;
138-
139134 const folderContextValue = useMemo (
140135 ( ) => ( { isExpanded, name, path } ) ,
141136 [ isExpanded , name , path ]
142137 ) ;
143138
144139 return (
145140 < FileTreeFolderContext . Provider value = { folderContextValue } >
146- < Collapsible onOpenChange = { handleOpenChange } open = { isExpanded } >
141+ < Collapsible onOpenChange = { handleToggle } open = { isExpanded } >
147142 < div
148143 className = { cn ( "" , className ) }
149144 role = "treeitem"
150145 tabIndex = { 0 }
151146 { ...props }
152147 >
153- < CollapsibleTrigger asChild >
154- < button
155- className = { cn (
156- "flex w-full items-center gap-1 rounded px-2 py-1 text-left transition-colors hover:bg-muted/50" ,
157- isSelected && "bg-muted"
148+ < div
149+ className = "flex w-full items-center gap-1 rounded px-2 py-1 text-left transition-colors hover:bg-muted/50"
150+ >
151+ < CollapsibleTrigger asChild >
152+ < button
153+ type = "button"
154+ className = "shrink-0 rounded p-0.5 hover:bg-muted"
155+ onClick = { ( e ) => e . stopPropagation ( ) }
156+ >
157+ < ChevronRightIcon
158+ className = { cn (
159+ "size-4 text-muted-foreground transition-transform" ,
160+ isExpanded && "rotate-90"
161+ ) }
162+ />
163+ </ button >
164+ </ CollapsibleTrigger >
165+ < FileTreeIcon >
166+ { isExpanded ? (
167+ < FolderOpenIcon className = "size-4 text-blue-500" />
168+ ) : (
169+ < FolderIcon className = "size-4 text-blue-500" />
158170 ) }
159- onClick = { handleSelect }
160- type = "button"
161- >
162- < ChevronRightIcon
163- className = { cn (
164- "size-4 shrink-0 text-muted-foreground transition-transform" ,
165- isExpanded && "rotate-90"
166- ) }
167- />
168- < FileTreeIcon >
169- { isExpanded ? (
170- < FolderOpenIcon className = "size-4 text-blue-500" />
171- ) : (
172- < FolderIcon className = "size-4 text-blue-500" />
173- ) }
174- </ FileTreeIcon >
175- < FileTreeName > { name } </ FileTreeName >
176- </ button >
177- </ CollapsibleTrigger >
171+ </ FileTreeIcon >
172+ < FileTreeName > { name } </ FileTreeName >
173+ </ div >
178174 < CollapsibleContent >
179175 < div className = "ml-4 border-l pl-2" > { children } </ div >
180176 </ CollapsibleContent >
0 commit comments