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(dialog): resolve open-type button correctly #470

Merged
merged 1 commit into from
May 24, 2022
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
1 change: 1 addition & 0 deletions src/common/template/button.wxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template name="button">
<t-button
block="{{block}}"
class="{{class}}"
t-class="{{externalClass}}"
disabled="{{disabled}}"
data-type="{{type}}"
Expand Down
10 changes: 8 additions & 2 deletions src/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ export default class Dialog extends SuperComponent {
onTplButtonTap(e) {
const evtType = e.type;
const { type } = e.target.dataset;
const button = this.data[`${type}Btn`];
const cbName = `bind${evtType}`;

if (`bind${evtType}` in this.data[`${type}Btn`]) {
this.data[`${type}Btn`][`bind${evtType}`](e.detail);
if (typeof button[cbName] === 'function') {
button[cbName](e);
}
if (evtType !== 'tap') {
const success = e.detail?.errMsg.indexOf('ok') > -1;
this.triggerEvent(success ? 'open-type-event' : 'open-type-error-event', e.detail);
}
},

Expand Down
3 changes: 1 addition & 2 deletions src/dialog/dialog.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
<block wx:elif="{{_.getTypeof(confirmBtn) == 'object'}}">
<template
is="button"
class="{{classPrefix}}__footer-button-host"
data="{{...confirmBtn, block: true, type: 'confirm', externalClass: classPrefix + '__button ' + classPrefix + '__button-confirm ' + (cancelBtn ? classPrefix + '__button-half ' : ' ') + prefix + '-class-confirm'}}"
data="{{...confirmBtn, block: true, type: 'confirm', externalClass: classPrefix + '__button ' + classPrefix + '__button-confirm ' + (cancelBtn ? classPrefix + '__button-half ' : ' ') + prefix + '-class-confirm', class: classPrefix + '__footer-button-host'}}"
></template>
</block>
<slot name="confirmBtn" />
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const props: TdDialogProps = {
},
/** 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。使用 TNode 自定义按钮时,需自行控制确认事件 */
confirmBtn: {
type: String,
type: null,
optionalTypes: [Object],
value: '',
},
Expand Down