fix #11307 Prop destroyOnClose prevents the closing animation of drawer

This commit is contained in:
陈帅 2018-07-18 15:52:51 +08:00
parent a2c4b03d45
commit e7242f4924
3 changed files with 17 additions and 11 deletions

View File

@ -46,7 +46,11 @@ exports[`Drawer destroyOnClose is true 1`] = `
>
<div
class="ant-drawer-content"
/>
>
<div
style="overflow: auto; height: 100%; width: 256px;"
/>
</div>
</div>
</div>
</div>

View File

@ -108,8 +108,16 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
}
renderBody = () => {
const { destroyOnClose, visible, width, placement } = this.props;
let containerStyle: React.CSSProperties = { width };
if (placement === 'left' || placement === 'right') {
containerStyle = {
overflow: 'auto',
height: '100%',
width,
};
}
if (destroyOnClose && !visible) {
return null;
return <div style={containerStyle}/>;
}
const { prefixCls, title, closable } = this.props;
let header;
@ -132,14 +140,7 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
</button>
);
}
let containerStyle: React.CSSProperties = { width };
if (placement === 'left' || placement === 'right') {
containerStyle = {
overflow: 'auto',
height: '100%',
width,
};
}
return (
<div style={containerStyle}>
{header}
@ -172,6 +173,7 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
showMask={this.props.mask}
placement={placement}
style={RcDrawerStyle}
class={this.props.wrapClassName}
>
{this.renderBody()}
</RcDrawer>

View File

@ -59,7 +59,7 @@
"rc-checkbox": "~2.1.5",
"rc-collapse": "~1.9.0",
"rc-dialog": "~7.1.0",
"rc-drawer": "~1.5.3",
"rc-drawer": "~1.5.7",
"rc-dropdown": "~2.2.0",
"rc-editor-mention": "^1.0.2",
"rc-form": "^2.1.0",