mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
Fixed mode of Menu inside Dropdown, close #6101
This commit is contained in:
parent
9226746ba7
commit
10a2d82731
@ -18,7 +18,7 @@ import { Menu, Dropdown, Icon } from 'antd';
|
||||
const SubMenu = Menu.SubMenu;
|
||||
|
||||
const menu = (
|
||||
<Menu>
|
||||
<Menu mode="inline">
|
||||
<Menu.Item>1st menu item</Menu.Item>
|
||||
<Menu.Item>2nd menu item</Menu.Item>
|
||||
<SubMenu title="sub menu">
|
||||
|
@ -1,6 +1,7 @@
|
||||
import React, { cloneElement } from 'react';
|
||||
import RcDropdown from 'rc-dropdown';
|
||||
import classNames from 'classnames';
|
||||
import warning from 'warning/warning';
|
||||
|
||||
export interface DropDownProps {
|
||||
trigger?: ('click' | 'hover')[];
|
||||
@ -31,13 +32,29 @@ export default class Dropdown extends React.Component<DropDownProps, any> {
|
||||
return 'slide-up';
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { overlay } = this.props;
|
||||
const overlayProps = (overlay as any).props as any;
|
||||
warning(
|
||||
!overlayProps.mode || overlayProps.mode === 'vertical',
|
||||
`mode="${overlayProps.mode}" is not supported for Dropdown\'s Menu.`,
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { children, prefixCls } = this.props;
|
||||
const { children, prefixCls, overlay } = this.props;
|
||||
const dropdownTrigger = cloneElement(children as any, {
|
||||
className: classNames((children as any).props.className, `${prefixCls}-trigger`),
|
||||
});
|
||||
const fixedModeOverlay = cloneElement(overlay as any, {
|
||||
mode: 'vertical',
|
||||
});
|
||||
return (
|
||||
<RcDropdown transitionName={this.getTransitionName()} {...this.props}>
|
||||
<RcDropdown
|
||||
transitionName={this.getTransitionName()}
|
||||
{...this.props}
|
||||
overlay={fixedModeOverlay}
|
||||
>
|
||||
{dropdownTrigger}
|
||||
</RcDropdown>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user