Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
auto position mode when contextMenu
  • Loading branch information
zombieJ committed Jun 12, 2018
1 parent fd96967 commit 16e4260
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/dropdown/demo/context-menu.md
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion components/dropdown/dropdown.tsx
Expand Up @@ -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}
Expand Down
1 change: 0 additions & 1 deletion components/dropdown/index.en-US.md
Expand Up @@ -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`.

Expand Down
1 change: 0 additions & 1 deletion components/dropdown/index.zh-CN.md
Expand Up @@ -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`

Expand Down

0 comments on commit 16e4260

Please sign in to comment.