Permalink
Browse files

auto position mode when contextMenu

  • Loading branch information...
zombieJ committed Jun 12, 2018
1 parent fd96967 commit 16e42601d6772fc0830ee237a1e751a38a118676
@@ -25,7 +25,7 @@ const menu = (
);
ReactDOM.render(
<Dropdown overlay={menu} trigger={['contextMenu']} alignPoint>
<Dropdown overlay={menu} trigger={['contextMenu']}>
<span style={{ userSelect: 'none' }}>Right Click on Me</span>
</Dropdown>
, mountNode);
@@ -68,11 +68,19 @@ export default class Dropdown extends React.Component<DropDownProps, any> {
selectable,
focusable,
});
const triggerActions = disabled ? [] : trigger;
let alignPoint;
if (triggerActions && triggerActions.indexOf('contextMenu') !== -1) {
alignPoint = true;
}
return (
<RcDropdown
alignPoint={alignPoint}
{...this.props}
transitionName={this.getTransitionName()}
trigger={disabled ? [] : trigger}
trigger={triggerActions}
overlay={fixedModeOverlay}
>
{dropdownTrigger}
@@ -23,7 +23,6 @@ If there are too many operations to display, you can wrap them in a `Dropdown`.
| trigger | the trigger mode which executes the drop-down action | Array&lt;`click`\|`hover`\|`contextMenu`> | `['hover']` |
| visible | whether the dropdown menu is visible | boolean | - |
| onVisibleChange | a callback function takes an argument: `visible`, is executed when the visible state is changed | Function(visible) | - |
| alignPoint | whether the dropdown menu follow the mouse position | bool | - |
You should use [Menu](/components/menu/) as `overlay`. The menu items and dividers are also available by using `Menu.Item` and `Menu.Divider`.
@@ -24,7 +24,6 @@ title: Dropdown
| trigger | 触发下拉的行为 | Array&lt;`click`\|`hover`\|`contextMenu`> | `['hover']` |
| visible | 菜单是否显示 | boolean | - |
| onVisibleChange | 菜单显示状态改变时调用,参数为 visible | Function(visible) | - |
| alignPoint | 菜单是否跟随鼠标位置 | bool | - |
`overlay` 菜单使用 [Menu](/components/menu/),还包括菜单项 `Menu.Item`,分割线 `Menu.Divider`。

0 comments on commit 16e4260

Please sign in to comment.