Emends B47 so focusing the input clears strip/summary before typing; hardens hit rows against blur-before-click.
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import type { ReactNode } from 'react'
|
|
|
|
import { MunicipalityPriorityIndicator } from '@/components/campaign/municipality/MunicipalityPriorityIndicator'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
const HOME_SEARCH_PRIORITY_ICON_SLOT_CLASS = 'flex w-4 shrink-0 justify-center'
|
|
|
|
export const HomeSearchHitRow = ({
|
|
href,
|
|
primary,
|
|
secondary,
|
|
trailing,
|
|
showPriority = false,
|
|
}: {
|
|
href: string
|
|
primary: string
|
|
secondary?: string
|
|
trailing?: ReactNode
|
|
showPriority?: boolean
|
|
}) => (
|
|
<Link
|
|
href={href}
|
|
onMouseDown={(event) => {
|
|
// Combobox/list precedent: RelationChipCell — keep input focused until navigation (B66).
|
|
event.preventDefault()
|
|
}}
|
|
className={cn(
|
|
'flex min-h-11 w-full items-center gap-3 py-2.5 text-left text-foreground',
|
|
'rounded-md outline-none hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring',
|
|
)}
|
|
>
|
|
<span className={HOME_SEARCH_PRIORITY_ICON_SLOT_CLASS} aria-hidden={!showPriority}>
|
|
{showPriority ? <MunicipalityPriorityIndicator /> : null}
|
|
</span>
|
|
<span className="min-w-0 flex-1">
|
|
<span className="block truncate font-medium">{primary}</span>
|
|
{secondary ? (
|
|
<span className="block truncate text-xs text-muted-foreground">{secondary}</span>
|
|
) : null}
|
|
</span>
|
|
{trailing ? <span className="shrink-0">{trailing}</span> : null}
|
|
</Link>
|
|
)
|