Fix Popconfirm defaultVisible

close #12733
pull/12744/head
afc163 6 years ago
parent cb24060955
commit faa5eaef12

@ -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();
});
});

@ -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;
}

Loading…
Cancel
Save