Fix Popconfirm defaultVisible

close #12733
This commit is contained in:
afc163 2018-10-19 23:57:16 +08:00
parent cb24060955
commit faa5eaef12
2 changed files with 11 additions and 0 deletions

View File

@ -117,4 +117,13 @@ describe('Popconfirm', () => {
expect(wrapper.find('.custom-popconfirm').length).toBeGreaterThan(0);
expect(wrapper.find('.custom-btn').length).toBeGreaterThan(0);
});
it('should support defaultVisible', () => {
const popconfirm = mount(
<Popconfirm title="code" defaultVisible>
<span>show me your code</span>
</Popconfirm>
);
expect(popconfirm.instance().getPopupDomNode()).toBeTruthy();
});
});

View File

@ -42,6 +42,8 @@ class Popconfirm extends React.Component<PopconfirmProps, PopconfirmState> {
static getDerivedStateFromProps(nextProps: PopconfirmProps) {
if ('visible' in nextProps) {
return { visible: nextProps.visible };
} else if ('defaultVisible' in nextProps) {
return { visible: nextProps.defaultVisible };
}
return null;
}