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): 修正 destroyOnClose 属性传递和 dialog 实例生成和返回 #1149

Merged
merged 4 commits into from
Nov 22, 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
28 changes: 0 additions & 28 deletions src/dialog/__test__/__snapshots__/demo.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ exports[`Dialog > Dialog confirmVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -146,7 +145,6 @@ exports[`Dialog > Dialog confirmVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -254,7 +252,6 @@ exports[`Dialog > Dialog feedbackVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -347,7 +344,6 @@ exports[`Dialog > Dialog feedbackVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -436,7 +432,6 @@ exports[`Dialog > Dialog feedbackVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -539,7 +534,6 @@ exports[`Dialog > Dialog imageDialogVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>

<div
Expand Down Expand Up @@ -692,7 +686,6 @@ exports[`Dialog > Dialog imageDialogVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -850,7 +843,6 @@ exports[`Dialog > Dialog inputVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -999,7 +991,6 @@ exports[`Dialog > Dialog inputVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -1187,7 +1178,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -1280,7 +1270,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -1369,7 +1358,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -1483,7 +1471,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -1589,7 +1576,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -1712,7 +1698,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -1861,7 +1846,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -2033,7 +2017,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>

<div
Expand Down Expand Up @@ -2186,7 +2169,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -2359,7 +2341,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -2465,7 +2446,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -2571,7 +2551,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -2677,7 +2656,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -2800,7 +2778,6 @@ exports[`Dialog > Dialog mobileVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -2968,7 +2945,6 @@ exports[`Dialog > Dialog multiStateVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -3074,7 +3050,6 @@ exports[`Dialog > Dialog multiStateVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -3180,7 +3155,6 @@ exports[`Dialog > Dialog multiStateVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -3286,7 +3260,6 @@ exports[`Dialog > Dialog multiStateVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down Expand Up @@ -3409,7 +3382,6 @@ exports[`Dialog > Dialog multiStateVue demo works fine 1`] = `

<div
class="t-dialog"
id="root"
>


Expand Down
1 change: 1 addition & 0 deletions src/dialog/dialog.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ width | String / Number | - | \- | N
zIndex | Number | - | \- | N
onCancel | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N
onClose | Function | | Typescript:`(context: DialogCloseContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/dialog/type.ts)。<br/>`type DialogEventSource = 'cancel' \| 'overlay'`<br/><br/>`interface DialogCloseContext { trigger: DialogEventSource; e: MouseEvent }`<br/> | N
onClosed | Function | | Typescript:`() => void`<br/> | N
onConfirm | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N
onOverlayClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N

Expand Down
1 change: 1 addition & 0 deletions src/dialog/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ width | String / Number | - | 对话框宽度,示例:320, '500px', '80%' | N
zIndex | Number | - | 对话框层级,Web 侧样式默认为 2500,移动端和小程序样式默认为 1500 | N
onCancel | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>如果“取消”按钮存在,则点击“取消”按钮时触发,同时触发关闭事件 | N
onClose | Function | | TS 类型:`(context: DialogCloseContext) => void`<br/>关闭事件,点击 取消按钮 或 点击蒙层 时触发。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/dialog/type.ts)。<br/>`type DialogEventSource = 'cancel' \| 'overlay'`<br/><br/>`interface DialogCloseContext { trigger: DialogEventSource; e: MouseEvent }`<br/> | N
onClosed | Function | | TS 类型:`() => void`<br/>组件关闭且动画结束后执行。 | N
onConfirm | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>如果“确认”按钮存在,则点击“确认”按钮时触发 | N
onOverlayClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>如果蒙层存在,点击蒙层时触发 | N

Expand Down
11 changes: 9 additions & 2 deletions src/dialog/dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
:show-overlay="showOverlay"
:overlay-props="overlayProps"
:prevent-scroll-through="preventScrollThrough"
:destroy-on-close="destroyOnClose"
@close="handleOverlayClick"
@closed="handleClosed"
>
<div id="root" :class="`${name}`" :style="rootStyles">
<div :class="`${name}`" :style="rootStyles">
<slot name="top" />
<div v-if="closeBtn" :class="`${name}__close-btn`">
<close-icon @click="handleClose" />
Expand Down Expand Up @@ -68,7 +70,7 @@ export default defineComponent({
name,
components: { TPopup, TNode, TButton, CloseIcon },
props: DialogProps,
emits: ['update:visible', 'confirm', 'overlay-click', 'cancel', 'close'],
emits: ['update:visible', 'confirm', 'overlay-click', 'cancel', 'close', 'closed'],
setup(props, context) {
const internalInstance = getCurrentInstance();
const contentNode = computed(() => renderContent(internalInstance, 'default', 'content'));
Expand Down Expand Up @@ -104,6 +106,10 @@ export default defineComponent({
context.emit('close', { e, trigger: 'close-btn' });
};

const handleClosed = () => {
context.emit('closed');
};

const handleConfirm = (e: MouseEvent) => {
context.emit('update:visible', false);
context.emit?.('confirm', { e });
Expand Down Expand Up @@ -146,6 +152,7 @@ export default defineComponent({
cancelBtnProps,
actionsBtnProps,
handleClose,
handleClosed,
handleConfirm,
handleCancel,
handleOverlayClick,
Expand Down
Loading
Loading