Skip to content

Commit 4278766

Browse files
committed
fix: drawer wrapStyle position is incorrect and add drawerStyle #1699
1 parent 0dbea62 commit 4278766

File tree

4 files changed

+56
-46
lines changed

4 files changed

+56
-46
lines changed

components/drawer/index.en-US.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
## API
22

3-
| Property | Description | Type | Default |
4-
| --- | --- | --- | --- |
5-
| closable | Whether a close (x) button is visible on top right of the Drawer dialog or not. | boolean | true |
6-
| destroyOnClose | Whether to unmount child components on closing drawer or not. | boolean | false |
7-
| getContainer | Return the mounted node for Drawer. | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' |
8-
| mask | Whether to show mask or not. | Boolean | true |
9-
| maskClosable | Clicking on the mask (area outside the Drawer) to close the Drawer or not. | boolean | true |
10-
| maskStyle | Style for Drawer's mask element. | object | {} |
11-
| title | The title for Drawer. | string\|slot | - |
12-
| visible | Whether the Drawer dialog is visible or not. | boolean | false |
13-
| wrapClassName | The class name of the container of the Drawer dialog. | string | - |
14-
| wrapStyle | The style of the container of the Drawer dialog. | object | - |
15-
| bodyStyle | Style of floating layer, typically used for adjusting its position. | object | - |
16-
| width | Width of the Drawer dialog. | string\|number | 256 |
17-
| height | placement is `top` or `bottom`, height of the Drawer dialog. | string\|number | - |
18-
| zIndex | The `z-index` of the Drawer. | Number | 1000 |
19-
| placement | The placement of the Drawer. | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' |
20-
| handle | After setting, the drawer is directly mounted on the DOM, and you can control the drawer to open or close through this `handle`. | VNode \| slot | - |
3+
| Property | Description | Type | Default | Version |
4+
| --- | --- | --- | --- | --- |
5+
| closable | Whether a close (x) button is visible on top right of the Drawer dialog or not. | boolean | true | |
6+
| destroyOnClose | Whether to unmount child components on closing drawer or not. | boolean | false | |
7+
| getContainer | Return the mounted node for Drawer. | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' | |
8+
| mask | Whether to show mask or not. | Boolean | true | |
9+
| maskClosable | Clicking on the mask (area outside the Drawer) to close the Drawer or not. | boolean | true | |
10+
| maskStyle | Style for Drawer's mask element. | object | {} | |
11+
| title | The title for Drawer. | string\|slot | - | |
12+
| visible | Whether the Drawer dialog is visible or not. | boolean | false | |
13+
| wrapClassName | The class name of the container of the Drawer dialog. | string | - | |
14+
| wrapStyle | Style of wrapper element which **contains mask** compare to `drawerStyle` | object | - | |
15+
| drawerStyle | Style of the popup layer element | object | - | 1.4.11 |
16+
| bodyStyle | Style of the drawer content part | object | - | |
17+
| width | Width of the Drawer dialog. | string\|number | 256 | |
18+
| height | placement is `top` or `bottom`, height of the Drawer dialog. | string\|number | - | |
19+
| zIndex | The `z-index` of the Drawer. | Number | 1000 | |
20+
| placement | The placement of the Drawer. | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' | |
21+
| handle | After setting, the drawer is directly mounted on the DOM, and you can control the drawer to open or close through this `handle`. | VNode \| slot | - | |
2122

2223
## Methods
2324

24-
| Name | Description | Type | Default |
25-
| --- | --- | --- | --- |
26-
| close | Specify a callback that will be called when a user clicks mask, close button or Cancel button. | function(e) | - |
25+
| Name | Description | Type | Default | Version |
26+
| --- | --- | --- | --- | --- |
27+
| close | Specify a callback that will be called when a user clicks mask, close button or Cancel button. | function(e) | - | |

components/drawer/index.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Drawer = {
1818
maskStyle: PropTypes.object,
1919
wrapStyle: PropTypes.object,
2020
bodyStyle: PropTypes.object,
21+
drawerStyle: PropTypes.object,
2122
title: PropTypes.any,
2223
visible: PropTypes.bool,
2324
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).def(256),
@@ -107,11 +108,12 @@ const Drawer = {
107108
}
108109
},
109110
getRcDrawerStyle() {
110-
const { zIndex, placement } = this.$props;
111+
const { zIndex, placement, wrapStyle } = this.$props;
111112
const { _push: push } = this.$data;
112113
return {
113114
zIndex,
114115
transform: push ? this.getPushTransform(placement) : undefined,
116+
...wrapStyle,
115117
};
116118
},
117119
renderHeader(prefixCls) {
@@ -142,7 +144,7 @@ const Drawer = {
142144
return null;
143145
}
144146
this.destroyClose = false;
145-
const { placement, bodyStyle, wrapStyle } = this.$props;
147+
const { placement, bodyStyle, drawerStyle } = this.$props;
146148

147149
const containerStyle =
148150
placement === 'left' || placement === 'right'
@@ -162,7 +164,7 @@ const Drawer = {
162164
return (
163165
<div
164166
class={`${prefixCls}-wrapper-body`}
165-
style={{ ...containerStyle, ...wrapStyle }}
167+
style={{ ...containerStyle, ...drawerStyle }}
166168
onTransitionend={this.onDestroyTransitionEnd}
167169
>
168170
{this.renderHeader(prefixCls)}

components/drawer/index.zh-CN.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
## API
22

3-
| 参数 | 说明 | 类型 | 默认值 |
4-
| --- | --- | --- | --- |
5-
| closable | 是否显示右上角的关闭按钮 | boolean | true |
6-
| destroyOnClose | 关闭时销毁 Drawer 里的子元素 | boolean | false |
7-
| getContainer | 指定 Drawer 挂载的 HTML 节点 | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' |
8-
| maskClosable | 点击蒙层是否允许关闭 | boolean | true |
9-
| mask | 是否展示遮罩 | Boolean | true |
10-
| maskStyle | 遮罩样式 | object | {} |
11-
| title | 标题 | string \| slot | - |
12-
| visible | Drawer 是否可见 | boolean | - |
13-
| wrapClassName | 对话框外层容器的类名 | string | - |
14-
| wrapStyle | 对话框外层容器的`style` | object | - |
15-
| bodyStyle | 可用于设置 Drawer 的样式,调整浮层位置等 | object | - |
16-
| width | 宽度 | string \| number | 256 |
17-
| height | 高度, 在 `placement``top``bottom` 时使用 | string \| number | 256 |
18-
| zIndex | 设置 Drawer 的 `z-index` | Number | 1000 |
19-
| placement | 抽屉的方向 | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' |
20-
| handle | 设置后抽屉直接挂载到 DOM 上,你可以通过该 handle 控制抽屉打开关闭 | VNode \| slot | - |
3+
| 参数 | 说明 | 类型 | 默认值 | 版本 |
4+
| --- | --- | --- | --- | --- |
5+
| closable | 是否显示右上角的关闭按钮 | boolean | true | |
6+
| destroyOnClose | 关闭时销毁 Drawer 里的子元素 | boolean | false | |
7+
| getContainer | 指定 Drawer 挂载的 HTML 节点 | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' | |
8+
| maskClosable | 点击蒙层是否允许关闭 | boolean | true | |
9+
| mask | 是否展示遮罩 | Boolean | true | |
10+
| maskStyle | 遮罩样式 | object | {} | |
11+
| title | 标题 | string \| slot | - | |
12+
| visible | Drawer 是否可见 | boolean | - | |
13+
| wrapClassName | 对话框外层容器的类名 | string | - | |
14+
| wrapStyle | 可用于设置 Drawer 最外层容器的样式,和 `drawerStyle` 的区别是作用节点包括 `mask` | object | - | |
15+
| drawerStyle | 用于设置 Drawer 弹出层的样式 | object | - | 1.4.11 |
16+
| bodyStyle | 可用于设置 Drawer 内容部分的样式 | object | - | |
17+
| width | 宽度 | string \| number | 256 | |
18+
| height | 高度, 在 `placement``top``bottom` 时使用 | string \| number | 256 | |
19+
| zIndex | 设置 Drawer 的 `z-index` | Number | 1000 | |
20+
| placement | 抽屉的方向 | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' | |
21+
| handle | 设置后抽屉直接挂载到 DOM 上,你可以通过该 handle 控制抽屉打开关闭 | VNode \| slot | - | |
2122

2223
## 方法
2324

24-
| 名称 | 描述 | 类型 | 默认值 |
25-
| ----- | ------------------------------------ | ----------- | ------ |
26-
| close | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) ||
25+
| 名称 | 描述 | 类型 | 默认值 | 版本 |
26+
| ----- | ------------------------------------ | ----------- | ------ | ---- |
27+
| close | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) || |

types/drawer.d.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,17 @@ export declare class Drawer extends AntdComponent {
6767
wrapClassName: string;
6868

6969
/**
70-
* The style of the container of the Drawer dialog.
70+
* Style of wrapper element which **contains mask** compare to `drawerStyle`
7171
* @type object
7272
*/
7373
wrapStyle: object;
7474

75+
/**
76+
* Style of the popup layer element
77+
* @type object
78+
*/
79+
drawerStyle: object;
80+
7581
/**
7682
* Style of floating layer, typically used for adjusting its position.
7783
* @type object

0 commit comments

Comments
 (0)