Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions src/DropdownMenu.tsx
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down Expand Up @@ -34,26 +34,23 @@ function DropdownMenu(props: DropdownMenuProps) {
}}
onFocus={onFocus}
onBlur={onBlur}
>
{options.map((option, index) => {
const { key, disabled, className, style, label } = option;
return (
<MenuItem
key={key}
disabled={disabled}
className={className}
style={style}
onMouseEnter={() => {
setActiveIndex(index);
}}
>
{label}
</MenuItem>
);
})}

{!options.length && <MenuItem disabled>{notFoundContent}</MenuItem>}
</Menu>
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 }]
}
/>
);
}

Expand Down