diff --git a/src/DropdownMenu.tsx b/src/DropdownMenu.tsx index 637070d..540db23 100644 --- a/src/DropdownMenu.tsx +++ b/src/DropdownMenu.tsx @@ -1,7 +1,7 @@ -import Menu, { MenuItem } from 'rc-menu'; +import Menu from 'rc-menu'; import * as React from 'react'; -import MentionsContext from './MentionsContext'; import type { DataDrivenOptionProps } from './Mentions'; +import MentionsContext from './MentionsContext'; interface DropdownMenuProps { prefixCls?: string; options: DataDrivenOptionProps[]; @@ -34,26 +34,23 @@ function DropdownMenu(props: DropdownMenuProps) { }} onFocus={onFocus} onBlur={onBlur} - > - {options.map((option, index) => { - const { key, disabled, className, style, label } = option; - return ( - { - setActiveIndex(index); - }} - > - {label} - - ); - })} - - {!options.length && {notFoundContent}} - + items={ + options.length > 0 + ? options.map( + ({ key, disabled, className, label, style }, index) => ({ + key, + disabled, + className, + style, + label, + onMouseEnter: () => { + setActiveIndex(index); + }, + }), + ) + : [{ key: 'not-found', disabled: true, label: notFoundContent }] + } + /> ); }