import { useEffect, useRef } from 'react'; import SubstringHighlight from './substring-highlight'; export type AutocompleteItemType = { id: string; pathLabel: string; itemLabel: string; items?: AutocompleteItemType[]; tags?: string[]; }; type AutocompleteItemProps = { item: AutocompleteItemType; active: boolean; substringToHighlight: string; handleOnClick: ( item: AutocompleteItemType | string, e: React.MouseEvent ) => void; }; const AutocompleteItem = ({ item, active, substringToHighlight, handleOnClick, }: AutocompleteItemProps) => { const nodeRef = useRef(null); useEffect(() => { if (active && nodeRef.current) { nodeRef.current.scrollIntoView({ block: 'nearest', inline: 'nearest' }); } }); return (
  • ); }; export default AutocompleteItem;