fix: menu-icon was not displayed in breadcrumbs for the home element
Massimo Melina committed
Apr 10, 2025 at 20:21 UTC
6301d29af0983fcaaac8cdaecc09fdc8924f7387
1 file changed
+10
-11
frontend/src/Breadcrumbs.ts
+10
-11
@@ -19,19 +19,18 @@ export function Breadcrumbs() {
19
const breadcrumbs = currentPath ? currentPath.split('/').map(x => [prev += x + '/', decodeURIComponent(x)]) : []
20
const {t} = useI18N()
21
return h(Fragment, {},
22
- h(Breadcrumb, { id: 'breadcrumb-parent', label: hIcon('parent', { alt: t`parent folder` }), path: parent }),
23
- h(Breadcrumb, { id: 'breadcrumb-home', label: hIcon('home', { alt: t`home` }), path: base, current: !currentPath }),
22
+ h(Breadcrumb, { id: 'breadcrumb-parent', path: parent, label: hIcon('parent', { alt: t`parent folder` }) }),
23
+ h(Breadcrumb, { id: 'breadcrumb-home', path: base, ...currentLabel(!currentPath, hIcon('home', { alt: t`home` })) }),
24
breadcrumbs.map(([path,label], i) =>
25
- h(Breadcrumb, {
26
- key: path,
27
- path,
28
- label,
29
- ...i === breadcrumbs.length - 1 && {
30
- current: true,
31
- label: h(Fragment, {}, label, hIcon('menu', { style: { position: 'relative', top: 1, marginLeft: '.3em' } }))
32
- },
33
- }) )
25
+ h(Breadcrumb, { key: path, path, ...currentLabel(i === breadcrumbs.length - 1, label) }) )
26
)
27
+
28
+ function currentLabel(isCurrent: boolean, label: string | ReactElement) {
29
+ return !isCurrent ? { label } : {
30
+ current: true,
31
+ label: h(Fragment, {}, label, hIcon('menu', { style: { position: 'relative', top: 1 } }))
32
+ }
33
+ }
34
}
35
36
function Breadcrumb({ path, label, current, ...rest }: { current?: boolean, path: string, label?: string | ReactElement } & Omit<LinkProps,'to'>) {