import Link from 'next/link' import type { ComponentProps, ReactNode } from 'react' import { cn, CommandItem } from 'ui' export interface CommandItemLinkProps extends Omit, 'children'> { href: ComponentProps['href'] linkProps?: Omit, 'children' | 'href'> children: ReactNode } /** * A command item that navigates with native link behaviour. * * The link must wrap the command item. Nesting a link inside a command item can * unmount the link when selection closes its menu before navigation completes. */ export function CommandItemLink({ href, linkProps, children, disabled, ...commandItemProps }: CommandItemLinkProps) { const commandItem = ( {children} ) return disabled ? ( commandItem ) : ( {commandItem} ) }