Skip to content

Commit 1ba0b84

Browse files
committed
fix: drawer class
1 parent f597775 commit 1ba0b84

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Drawer class is test_drawer 1`] = `
4-
<div>
4+
<div class="">
55
<div class="ant-drawer ant-drawer-right test_drawer">
66
<div class="ant-drawer-mask"></div>
77
<div class="ant-drawer-content-wrapper" style="transform: translateX(100%); width: 256px;">
@@ -16,7 +16,7 @@ exports[`Drawer class is test_drawer 1`] = `
1616
`;
1717

1818
exports[`Drawer closable is false 1`] = `
19-
<div>
19+
<div class="">
2020
<div class="ant-drawer ant-drawer-right">
2121
<div class="ant-drawer-mask"></div>
2222
<div class="ant-drawer-content-wrapper" style="transform: translateX(100%); width: 256px;">
@@ -31,7 +31,7 @@ exports[`Drawer closable is false 1`] = `
3131
`;
3232

3333
exports[`Drawer destroyOnClose is true 1`] = `
34-
<div>
34+
<div class="">
3535
<div class="ant-drawer ant-drawer-right">
3636
<div class="ant-drawer-mask"></div>
3737
<div class="ant-drawer-content-wrapper" style="transform: translateX(100%); width: 256px;">
@@ -46,7 +46,7 @@ exports[`Drawer destroyOnClose is true 1`] = `
4646
`;
4747

4848
exports[`Drawer have a title 1`] = `
49-
<div>
49+
<div class="">
5050
<div class="ant-drawer ant-drawer-right">
5151
<div class="ant-drawer-mask"></div>
5252
<div class="ant-drawer-content-wrapper" style="transform: translateX(100%); width: 256px;">
@@ -64,7 +64,7 @@ exports[`Drawer have a title 1`] = `
6464
`;
6565

6666
exports[`Drawer render correctly 1`] = `
67-
<div>
67+
<div class="">
6868
<div class="ant-drawer ant-drawer-right">
6969
<div class="ant-drawer-mask"></div>
7070
<div class="ant-drawer-content-wrapper" style="transform: translateX(100%); width: 400px;">
@@ -79,7 +79,7 @@ exports[`Drawer render correctly 1`] = `
7979
`;
8080

8181
exports[`Drawer render top drawer 1`] = `
82-
<div>
82+
<div class="">
8383
<div class="ant-drawer ant-drawer-top">
8484
<div class="ant-drawer-mask"></div>
8585
<div class="ant-drawer-content-wrapper" style="transform: translateY(-100%); height: 400px;">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`Drawer render correctly 1`] = `
44
<div><button type="button" class="ant-btn ant-btn-default"><span>open</span></button>
5-
<div>
5+
<div class="">
66
<div class="ant-drawer ant-drawer-right">
77
<div class="ant-drawer-mask"></div>
88
<div class="ant-drawer-content-wrapper" style="transform: translateX(100%); width: 256px;">

components/drawer/index.jsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import warning from 'warning'
2+
import classnames from 'classnames'
23
import VcDrawer from '../vc-drawer/src'
34
import PropTypes from '../_util/vue-types'
45
import BaseMixin from '../_util/BaseMixin'
56
import Icon from '../icon'
6-
import { getComponentFromProp, getOptionProps, getClass } from '../_util/props-util'
7+
import { getComponentFromProp, getOptionProps } from '../_util/props-util'
78

89
const Drawer = {
910
name: 'ADrawer',
@@ -22,14 +23,10 @@ const Drawer = {
2223
prefixCls: PropTypes.string.def('ant-drawer'),
2324
placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']).def('right'),
2425
level: PropTypes.any.def(null),
25-
wrapClassName: PropTypes.string,
26+
wrapClassName: PropTypes.string, // not use class like react, vue will add class to root dom
2627
},
2728
mixins: [BaseMixin],
2829
data () {
29-
warning(
30-
this.wrapClassName === undefined,
31-
'wrapClassName is deprecated, please use className instead.',
32-
)
3330
this.destoryClose = false
3431
this.preVisible = this.$props.visible
3532
return {
@@ -199,17 +196,16 @@ const Drawer = {
199196
open: visible,
200197
showMask: props.mask,
201198
placement,
199+
className: classnames({
200+
[wrapClassName]: !!wrapClassName,
201+
[haveMask]: !!haveMask,
202+
}),
202203
},
203204
on: {
204205
maskClick: this.onMaskClick,
205206
...this.$listeners,
206207
},
207208
style: this.getRcDrawerStyle(),
208-
class: {
209-
[wrapClassName]: !!wrapClassName,
210-
...getClass(this),
211-
[haveMask]: !!haveMask,
212-
},
213209
}
214210
return (
215211
<VcDrawer

components/form/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ exports[`renders ./components/form/demo/validate-other.vue correctly 1`] = `
581581
<div class="ant-row ant-form-item">
582582
<div class="ant-col-6 ant-form-item-label"><label for="upload" title="Upload" class="">Upload</label></div>
583583
<div class="ant-col-14 ant-form-item-control-wrapper">
584-
<div class="ant-form-item-control"><span class="ant-form-item-children"><span data-__meta="[object Object]" data-__field="[object Object]" id="upload" class=""><div class="ant-upload ant-upload-select ant-upload-select-picture"><!----></div><div class="ant-upload-list ant-upload-list-picture"></div></span></span>
584+
<div class="ant-form-item-control"><span class="ant-form-item-children"><span class=""><div class="ant-upload ant-upload-select ant-upload-select-picture"><!----></div><div class="ant-upload-list ant-upload-list-picture"></div></span></span>
585585
<!---->
586586
<div class="ant-form-extra">longgggggggggggggggggggggggggggggggggg</div>
587587
</div>

components/vc-drawer/src/Drawer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const Drawer = {
4141
handler: true,
4242
maskStyle: {},
4343
wrapperClassName: '',
44+
className: '',
4445
}),
4546
data () {
4647
this.levelDom = []
@@ -367,6 +368,7 @@ const Drawer = {
367368
},
368369
getChildToRender (open) {
369370
const {
371+
className,
370372
prefixCls,
371373
placement,
372374
handler,
@@ -379,7 +381,7 @@ const Drawer = {
379381
const wrapperClassname = classnames(prefixCls, {
380382
[`${prefixCls}-${placement}`]: true,
381383
[`${prefixCls}-open`]: open,
382-
...getClass(this),
384+
[className]: !!className,
383385
})
384386
const isOpenChange = this.isOpenChange
385387
const isHorizontal = placement === 'left' || placement === 'right'

components/vc-drawer/src/drawerProps.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export default {
1717
handler: PropTypes.any,
1818
showMask: PropTypes.bool,
1919
maskStyle: PropTypes.object,
20+
className: PropTypes.string,
2021
}

tests/__snapshots__/index.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Array [
5858
"Upload",
5959
"Drawer",
6060
"Skeleton",
61+
"Comment",
6162
"default",
6263
]
6364
`;

0 commit comments

Comments
 (0)