Skip to content

Commit

Permalink
Merge 555bfd2 into 565a8d6
Browse files Browse the repository at this point in the history
  • Loading branch information
minosss authored Aug 23, 2023
2 parents 565a8d6 + 555bfd2 commit 849e6f6
Showing 1 changed file with 19 additions and 22 deletions.
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

0 comments on commit 849e6f6

Please sign in to comment.