Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(drawer): resolve close event #1686

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/drawer/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ name | type | default | description | required
-- | -- | -- | -- | --
close-on-overlay-click | Boolean | undefined | \- | N
destroy-on-close | Boolean | false | \- | N
footer | Slot | - | \- | N
items | Array | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/drawer/type.ts) | N
footer | Slot | - | `0.29.0` | N
items | Array | - | Typescript:`DrawerItem[] ` `interface DrawerItem { title: string; icon: string; }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/drawer/type.ts) | N
placement | String | right | options:left/right | N
show-overlay | Boolean | true | \- | N
title | String / Slot | '' | \- | N
title | String / Slot | - | `0.29.0` | N
visible | Boolean | false | \- | N
z-index | Number | - | \- | N
z-index | Number | 11500 | \- | N

### Drawer Events

name | params | description
-- | -- | --
close | `(trigger: DrawerEventSource)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/drawer/type.ts)。<br/>`type DrawerEventSource = 'esc' \| 'close-btn' \| 'cancel' \| 'overlay'`<br/>
close | `(trigger: TriggerSource)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/drawer/type.ts)。<br/>`type TriggerSource = 'overlay'`<br/>
item-click | `(index: number; item: DrawerItem)` | \-
overlay-click | \- | \-
6 changes: 3 additions & 3 deletions src/drawer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ isComponent: true
-- | -- | -- | -- | --
close-on-overlay-click | Boolean | true | 点击蒙层时是否触发抽屉关闭事件 | N
destroy-on-close | Boolean | false | 抽屉关闭时是否销毁节点 | N
footer | Slot | - | `v0.29.0`。抽屉的底部 | N
footer | Slot | - | `0.29.0`。抽屉的底部 | N
items | Array | - | 抽屉里的列表项。TS 类型:`DrawerItem[] ` `interface DrawerItem { title: string; icon: string; }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/drawer/type.ts) | N
placement | String | right | 抽屉方向。可选项:left/right | N
show-overlay | Boolean | true | 是否显示遮罩层 | N
title | String / Slot | '' | `v0.29.0`。抽屉的标题 | N
title | String / Slot | - | `0.29.0`。抽屉的标题 | N
visible | Boolean | false | 组件是否可见 | N
z-index | Number | 11500 | 抽屉层级,样式默认为 11500 | N

### Drawer Events

名称 | 参数 | 描述
-- | -- | --
close | `(trigger: DrawerEventSource)` | 关闭事件,取消按钮点击时、关闭按钮点击时、点击蒙层时均会触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/drawer/type.ts)。<br/>`type DrawerEventSource = 'esc' \| 'close-btn' \| 'cancel' \| 'overlay'`<br/>
close | `(trigger: TriggerSource)` | 关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/drawer/type.ts)。<br/>`type TriggerSource = 'overlay'`<br/>
item-click | `(index: number; item: DrawerItem)` | 点击抽屉里的列表项
overlay-click | \- | 如果蒙层存在,点击蒙层时触发
7 changes: 6 additions & 1 deletion src/drawer/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ export default class Drawer extends SuperComponent {
const { showOverlay } = this.data;

this.setData({
visible: visible,
visible,
});

if (!visible) {
this.triggerEvent('close', { trigger: 'overlay' });
}

if (showOverlay) {
this.triggerEvent('overlay-click', { visible: visible });
}
},

itemClick(detail) {
const { index, item } = detail.currentTarget.dataset;

this.triggerEvent('item-click', {
sibarItem: { index: index, item: item },
});
Expand Down
1 change: 0 additions & 1 deletion src/drawer/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const props: TdDrawerProps = {
/** 抽屉的标题 */
title: {
type: String,
value: '',
},
/** 组件是否可见 */
visible: {
Expand Down
10 changes: 0 additions & 10 deletions src/drawer/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,11 @@
export interface TdDrawerProps {
/**
* 点击蒙层时是否触发抽屉关闭事件
* @default true
*/
closeOnOverlayClick?: {
type: BooleanConstructor;
value?: boolean;
};
/**
* 自定义组件样式
* @default ''
*/
style?: {
type: StringConstructor;
value?: string;
};
/**
* 抽屉关闭时是否销毁节点
* @default false
Expand Down Expand Up @@ -54,7 +45,6 @@ export interface TdDrawerProps {
};
/**
* 抽屉的标题
* @default ''
*/
title?: {
type: StringConstructor;
Expand Down