Skip to content

Commit 9a2348d

Browse files
fix: remove duplicate root button (#585)
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 746b2f9 commit 9a2348d

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

packages/workshop-app/app/components/file-app-explorer.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ function buildIndexes(files: Array<AppFile>): FileIndexes {
104104
}
105105

106106
function getBreadcrumbParts(pathValue: string | null): Array<BreadcrumbPart> {
107-
const breadcrumbs: Array<BreadcrumbPart> = [
108-
{ label: 'root', path: '', parentPath: '', isDirectory: true },
109-
]
107+
const breadcrumbs: Array<BreadcrumbPart> = []
110108
if (!pathValue) return breadcrumbs
111109

112110
const parts = pathValue.split('/').filter(Boolean)
@@ -459,16 +457,14 @@ export function FileAppExplorer({ appName }: { appName: string }) {
459457
className="scrollbar-thin scrollbar-thumb-scrollbar min-w-0 flex-1 overflow-x-auto"
460458
>
461459
<div className="flex w-max min-w-full items-center gap-1 pr-2">
460+
{breadcrumbs.length > 0 ? (
461+
<span className="text-muted-foreground text-xs">/</span>
462+
) : null}
462463
{breadcrumbs.map((crumb, index) => {
463-
const siblings =
464-
index === 0
465-
? indexes.childrenByDirectory.get('')
466-
: indexes.childrenByDirectory.get(crumb.parentPath)
467-
const isCurrent =
468-
crumb.path === selectedPath ||
469-
(index === 0 && selectedPath === null)
464+
const siblings = indexes.childrenByDirectory.get(crumb.parentPath)
465+
const isCurrent = crumb.path === selectedPath
470466
return (
471-
<React.Fragment key={`${crumb.path || 'root'}:${index}`}>
467+
<React.Fragment key={`${crumb.path}:${index}`}>
472468
<Popover>
473469
<PopoverTrigger asChild>
474470
<button

0 commit comments

Comments
 (0)