Browse Source

update drawer test

pull/11409/head
jljsj33 6 years ago
committed by 偏右
parent
commit
2cd863929a
  1. 16
      components/drawer/__tests__/__snapshots__/Drawer.test.js.snap
  2. 4
      components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap
  3. 12
      components/drawer/index.tsx
  4. 4
      components/drawer/style/drawer.less
  5. 2
      package.json

16
components/drawer/__tests__/__snapshots__/Drawer.test.js.snap

@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Drawer closable is false 1`] = `
<div>
<div
class=""
>
<div
class="ant-drawer ant-drawer-right"
>
@ -31,7 +33,9 @@ exports[`Drawer closable is false 1`] = `
`;
exports[`Drawer destroyOnClose is true 1`] = `
<div>
<div
class=""
>
<div
class="ant-drawer ant-drawer-right"
>
@ -69,7 +73,9 @@ exports[`Drawer destroyOnClose is true 1`] = `
`;
exports[`Drawer have a title 1`] = `
<div>
<div
class=""
>
<div
class="ant-drawer ant-drawer-right"
>
@ -116,7 +122,9 @@ exports[`Drawer have a title 1`] = `
`;
exports[`Drawer render correctly 1`] = `
<div>
<div
class=""
>
<div
class="ant-drawer ant-drawer-right"
>

4
components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap

@ -10,7 +10,9 @@ exports[`Drawer render correctly 1`] = `
open
</span>
</button>
<div>
<div
class=""
>
<div
class="ant-drawer ant-drawer-right ant-drawer-open"
>

12
components/drawer/index.tsx

@ -107,8 +107,7 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
});
}
onDestoryTransitionEnd = () => {
const { destroyOnClose, visible } = this.props;
const isDestroyOnClose = destroyOnClose && !visible;
const isDestroyOnClose = this.getDestoryOnClose();
if (!isDestroyOnClose) {
return;
}
@ -117,20 +116,23 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
this.forceUpdate();
}
}
getDestoryOnClose = () => (this.props.destroyOnClose && !this.props.visible);
renderBody = () => {
if (this.destoryClose && !this.props.visible) {
return null;
}
this.destoryClose = false;
const { destroyOnClose, visible, placement } = this.props;
const { placement } = this.props;
const containerStyle: React.CSSProperties = placement === 'left'
|| placement === 'right' ? {
overflow: 'auto',
height: '100%',
} : {};
const isDestroyOnClose = destroyOnClose && !visible;
const isDestroyOnClose = this.getDestoryOnClose();
if (isDestroyOnClose) {
// 增加透明渐变,跟关闭的动画时间相同,在关闭后删除子元素;
// Increase the opacity transition, delete children after closing.
containerStyle.opacity = 0;
containerStyle.transition = 'opacity .3s';
}

4
components/drawer/style/drawer.less

@ -28,7 +28,7 @@
&-left {
&.@{dawer-prefix-cls}-open {
.@{dawer-prefix-cls}-content-wrapper {
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
box-shadow: @shadow-1-right;
}
}
}
@ -40,7 +40,7 @@
}
&.@{dawer-prefix-cls}-open {
.@{dawer-prefix-cls}-content-wrapper {
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
box-shadow: @shadow-1-left;
}
}
}

2
package.json

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

Loading…
Cancel
Save