Skip to content

Commit 0628779

Browse files
fix(web): key crumbs by position, label the namespace crumb, guard edit
Breadcrumbs keyed each <li> by label, which collides when a user-authored title matches an ancestor crumb; key by index instead. TagDetail's namespace crumb showed the raw slug ("tech") while the page it links to is headed "Tech"; it now uses TagsNamespace's NS_LABELS so the crumb and the destination h1 agree. ProjectEdit rendered a blank crumb linking to /projects/ when the edit query settled without a record; hold the loading state in that case so the trail is only ever built from a loaded project. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RdRwHvDupRLV8GuJpYKzEr
1 parent f419c26 commit 0628779

4 files changed

Lines changed: 21 additions & 9 deletions

File tree

‎apps/web/src/components/Breadcrumbs.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function Breadcrumbs({ items }: BreadcrumbsProps) {
2121
{items.map((item, index) => {
2222
const isLast = index === items.length - 1;
2323
return (
24-
<li key={item.label} className="flex items-center gap-1">
24+
<li key={`${index}-${item.label}`} className="flex items-center gap-1">
2525
{index > 0 && (
2626
<span aria-hidden="true" className="text-muted-foreground/50">
2727
&rsaquo;

‎apps/web/src/screens/ProjectEdit.tsx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ export function ProjectEdit({ mode }: ProjectEditProps) {
159159

160160
const project = projectQ.data?.data;
161161

162+
// Settled with no record (the query can resolve empty before an error
163+
// surfaces): hold the loading state rather than rendering a form and a
164+
// blank crumb pointing at /projects/.
165+
if (mode === 'edit' && !project) {
166+
return <div className="container mx-auto px-4 py-12 text-muted-foreground">Loading project…</div>;
167+
}
168+
162169
if (mode === 'edit' && project && !project.permissions.canEdit) {
163170
return (
164171
<div className="container mx-auto px-4 py-16 text-center">
@@ -271,16 +278,18 @@ export function ProjectEdit({ mode }: ProjectEditProps) {
271278
return (
272279
<>
273280
{/* specs/behaviors/app-shell.md → Breadcrumbs:
274-
create → Projects › New project; edit → Projects › <title> › Edit */}
281+
create → Projects › New project; edit → Projects › <title> › Edit.
282+
`project` is only ever loaded in edit mode (the query is gated on
283+
it), and the guard above has already returned when it is missing. */}
275284
<Breadcrumbs
276285
items={
277-
mode === 'create'
278-
? [{ label: 'Projects', href: '/projects' }, { label: 'New project' }]
279-
: [
286+
project
287+
? [
280288
{ label: 'Projects', href: '/projects' },
281-
{ label: project?.title ?? '', href: `/projects/${project?.slug ?? ''}` },
289+
{ label: project.title, href: `/projects/${project.slug}` },
282290
{ label: 'Edit' },
283291
]
292+
: [{ label: 'Projects', href: '/projects' }, { label: 'New project' }]
284293
}
285294
/>
286295
<div className="container mx-auto px-4 py-8 max-w-3xl">

‎apps/web/src/screens/TagDetail.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ProjectCard } from '@/components/ProjectCard';
88
import { PersonCard } from '@/components/PersonCard';
99
import { HelpWantedCard } from '@/components/HelpWantedCard';
1010
import { TagEditModal } from '@/components/modals/TagEditModal';
11+
import { NS_LABELS } from '@/screens/TagsNamespace';
1112
import { useAuth } from '@/hooks/useAuth';
1213
import { api, ApiError } from '@/lib/api';
1314

@@ -104,11 +105,13 @@ export function TagDetail() {
104105

105106
return (
106107
<>
107-
{/* specs/behaviors/app-shell.md → Breadcrumbs: Tags › <namespace> › <title> */}
108+
{/* specs/behaviors/app-shell.md → Breadcrumbs: Tags › <namespace> › <title>.
109+
The namespace crumb carries the same display label as the page it
110+
links to (TagsNamespace's h1), not the raw slug. */}
108111
<Breadcrumbs
109112
items={[
110113
{ label: 'Tags', href: '/tags' },
111-
{ label: tag.namespace, href: `/tags/${tag.namespace}` },
114+
{ label: NS_LABELS[tag.namespace] ?? tag.namespace, href: `/tags/${tag.namespace}` },
112115
{ label: tag.title },
113116
]}
114117
/>

‎apps/web/src/screens/TagsNamespace.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TagChip } from '@/components/TagChip';
66
import { Pagination } from '@/components/Pagination';
77
import { api } from '@/lib/api';
88

9-
const NS_LABELS: Record<string, string> = {
9+
export const NS_LABELS: Record<string, string> = {
1010
topic: 'Topics',
1111
tech: 'Tech',
1212
event: 'Events',

0 commit comments

Comments
 (0)