fix: root label not applied for non-root dirs

fix breadcrumb root label not correctly displayed when breadcrumb is
displaying path for non-root dirs
This commit is contained in:
2025-10-05 00:54:22 +00:00
parent b43a88c6fc
commit 9149243e95

View File

@@ -30,7 +30,10 @@ export function FilePathBreadcrumb({ rootLabel }: { rootLabel: string }) {
breadcrumbItems.push( breadcrumbItems.push(
<Fragment key={directory.path[i]?.handle.id}> <Fragment key={directory.path[i]?.handle.id}>
<BreadcrumbSeparator /> <BreadcrumbSeparator />
<FilePathBreadcrumbItem component={directory.path[i]!} /> <FilePathBreadcrumbItem
component={directory.path[i]!}
rootLabel={rootLabel}
/>
</Fragment>, </Fragment>,
) )
} }
@@ -43,7 +46,10 @@ export function FilePathBreadcrumb({ rootLabel }: { rootLabel: string }) {
<BreadcrumbPage>{rootLabel}</BreadcrumbPage> <BreadcrumbPage>{rootLabel}</BreadcrumbPage>
</BreadcrumbItem> </BreadcrumbItem>
) : ( ) : (
<FilePathBreadcrumbItem component={directory.path[0]!} /> <FilePathBreadcrumbItem
component={directory.path[0]!}
rootLabel={rootLabel}
/>
)} )}
{breadcrumbItems} {breadcrumbItems}
<BreadcrumbSeparator /> <BreadcrumbSeparator />
@@ -55,13 +61,19 @@ export function FilePathBreadcrumb({ rootLabel }: { rootLabel: string }) {
) )
} }
function FilePathBreadcrumbItem({ component }: { component: PathComponent }) { function FilePathBreadcrumbItem({
component,
rootLabel,
}: {
component: PathComponent
rootLabel: string
}) {
const { isDraggedOver, dropHandlers } = useFileDrop({ const { isDraggedOver, dropHandlers } = useFileDrop({
destItem: component.handle as DirectoryHandle, destItem: component.handle as DirectoryHandle,
dragInfoAtom, dragInfoAtom,
}) })
const dirName = component.name || "All Files" const dirName = component.name || rootLabel
return ( return (
<Tooltip open={isDraggedOver}> <Tooltip open={isDraggedOver}>