Don't pass visible to Dropdown if it's not exits. (#3821)

fix #3815
pull/3885/head
Wei Zhu 8 years ago committed by 偏右
parent 8457267dad
commit b0c7a714ad

@ -43,16 +43,21 @@ export default class DropdownButton extends React.Component<DropdownButtonProps,
[className]: !!className,
});
const dropdownProps = {
align,
overlay,
trigger: disabled ? [] : trigger,
onVisibleChange,
};
if ('visible' in this.props) {
(dropdownProps as any).visible = visible;
}
return (
<ButtonGroup {...restProps} className={cls}>
<Button type={type} onClick={onClick} disabled={disabled}>{children}</Button>
<Dropdown
align={align}
overlay={overlay}
trigger={disabled ? [] : trigger}
visible={visible}
onVisibleChange={onVisibleChange}
>
<Dropdown {...dropdownProps}>
<Button type={type} disabled={disabled}>
<Icon type="down" />
</Button>

@ -26,4 +26,11 @@ describe('DropdownButton', () => {
expect(dropdownProps[key]).toBe(props[key]);
});
});
it('don\'t pass visible to Dropdown if it\'s not exits', () => {
const wrapper = shallow(<Dropdown.Button />);
const dropdownProps = wrapper.find(Dropdown).props();
expect('visible' in dropdownProps).toBe(false);
});
});

Loading…
Cancel
Save