Skip to content

Commit 71b5834

Browse files
committed
refactor(a11y): keep focused row diff minimal
1 parent 296f49c commit 71b5834

1 file changed

Lines changed: 41 additions & 44 deletions

File tree

src/components/map/results-list.tsx

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -83,52 +83,49 @@ export function ResultsList({
8383
</div>
8484
) : (
8585
<ul className="min-h-0 space-y-1 overflow-y-auto">
86-
{rows.map(({ place, distanceKm }) => {
87-
const focused = focusId === place.id;
88-
return (
89-
<li key={place.id}>
90-
<div
91-
className={`group flex items-center gap-2.5 rounded-md px-2 py-2 ${
92-
focused ? "bg-muted ring-1 ring-border" : "hover:bg-muted"
93-
}`}
86+
{rows.map(({ place, distanceKm }) => (
87+
<li key={place.id}>
88+
<div
89+
className={`group flex items-center gap-2.5 rounded-md px-2 py-2 ${
90+
focusId === place.id ? "bg-muted ring-1 ring-border" : "hover:bg-muted"
91+
}`}
92+
>
93+
<span
94+
aria-hidden
95+
className="size-3 shrink-0 rounded-full"
96+
style={{ backgroundColor: PLACE_TYPE_COLORS[place.type] }}
97+
/>
98+
<button
99+
type="button"
100+
onClick={() => onSelect(place)}
101+
aria-current={focusId === place.id ? "true" : undefined}
102+
className="min-w-0 flex-1 text-left"
103+
title={`${place.name} (${PLACE_TYPE_LABELS[place.type]})`}
94104
>
95-
<span
96-
aria-hidden
97-
className="size-3 shrink-0 rounded-full"
98-
style={{ backgroundColor: PLACE_TYPE_COLORS[place.type] }}
99-
/>
100-
<button
101-
type="button"
102-
onClick={() => onSelect(place)}
103-
aria-current={focused ? "true" : undefined}
104-
className="min-w-0 flex-1 text-left"
105-
title={`${place.name} (${PLACE_TYPE_LABELS[place.type]})`}
106-
>
107-
<span className="flex items-center gap-1.5">
108-
<span className="block truncate text-sm text-foreground">
109-
{place.name}
110-
</span>
111-
<VerifiedBadge place={place} />
105+
<span className="flex items-center gap-1.5">
106+
<span className="block truncate text-sm text-foreground">
107+
{place.name}
112108
</span>
113-
<span className="block truncate text-xs text-muted-foreground">
114-
{PLACE_TYPE_LABELS[place.type]}
115-
{distanceKm !== undefined && ` · ${formatDistance(distanceKm)}`}
116-
</span>
117-
</button>
118-
<a
119-
href={directionsUrl(place.lat, place.lng)}
120-
target="_blank"
121-
rel="noreferrer"
122-
onClick={(e) => e.stopPropagation()}
123-
aria-label={`Directions to ${place.name}`}
124-
className="shrink-0 rounded-md p-2 text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:bg-background focus-visible:text-foreground"
125-
>
126-
<Navigation className="size-4" />
127-
</a>
128-
</div>
129-
</li>
130-
);
131-
})}
109+
<VerifiedBadge place={place} />
110+
</span>
111+
<span className="block truncate text-xs text-muted-foreground">
112+
{PLACE_TYPE_LABELS[place.type]}
113+
{distanceKm !== undefined && ` · ${formatDistance(distanceKm)}`}
114+
</span>
115+
</button>
116+
<a
117+
href={directionsUrl(place.lat, place.lng)}
118+
target="_blank"
119+
rel="noreferrer"
120+
onClick={(e) => e.stopPropagation()}
121+
aria-label={`Directions to ${place.name}`}
122+
className="shrink-0 rounded-md p-2 text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:bg-background focus-visible:text-foreground"
123+
>
124+
<Navigation className="size-4" />
125+
</a>
126+
</div>
127+
</li>
128+
))}
132129
</ul>
133130
)}
134131
</div>

0 commit comments

Comments
 (0)