Skip to content

Commit

Permalink
feat(Dialog): add destroyOnClose prop to control content destruction …
Browse files Browse the repository at this point in the history
…on close (youzan#13382)
  • Loading branch information
inottn authored Mar 8, 2025
1 parent bfaceaf commit 1e390af
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/vant/src/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const dialogProps = extend({}, popupSharedProps, {
showConfirmButton: truthProp,
closeOnClickOverlay: Boolean,
keyboardEnabled: truthProp,
destroyOnClose: Boolean,
});

export type DialogProps = ExtractPropTypes<typeof dialogProps>;
Expand All @@ -71,6 +72,7 @@ const popupInheritKeys = [
...popupSharedPropKeys,
'transition',
'closeOnPopstate',
'destroyOnClose',
] as const;

export default defineComponent({
Expand Down
2 changes: 2 additions & 0 deletions packages/vant/src/dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Vant exports following Dialog utility functions:
| confirmButtonText | Confirm button text | _string_ | `Confirm` |
| confirmButtonColor | Confirm button color | _string_ | `#ee0a24` |
| confirmButtonDisabled | Whether to disable confirm button | _boolean_ | `false` |
| destroyOnClose `v4.9.18` | Whether to destroy content when closed | _boolean_ | `false` |
| overlay | Whether to show overlay | _boolean_ | `true` |
| overlayClass | Custom overlay class | _string \| Array \| object_ | - |
| overlayStyle | Custom overlay style | _object_ | - |
Expand Down Expand Up @@ -202,6 +203,7 @@ Vant exports following Dialog utility functions:
| confirm-button-text | Confirm button text | _string_ | `Confirm` |
| confirm-button-color | Confirm button color | _string_ | `#ee0a24` |
| confirm-button-disabled | Whether to disable confirm button | _boolean_ | `false` |
| destroy-on-close `v4.9.18` | Whether to destroy content when closed | _boolean_ | `false` |
| z-index | Set the z-index to a fixed value | _number \| string_ | `2000+` |
| overlay | Whether to show overlay | _boolean_ | `true` |
| overlay-class | Custom overlay class | _string_ | - |
Expand Down
2 changes: 2 additions & 0 deletions packages/vant/src/dialog/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Vant 中导出了以下 Dialog 相关的辅助函数:
| cancelButtonText | 取消按钮文案 | _string_ | `取消` |
| cancelButtonColor | 取消按钮颜色 | _string_ | `black` |
| cancelButtonDisabled | 是否禁用取消按钮 | _boolean_ | `false` |
| destroyOnClose `v4.9.18` | 是否在关闭时销毁内容 | _boolean_ | `false` |
| overlay | 是否展示遮罩层 | _boolean_ | `true` |
| overlayClass | 自定义遮罩层类名 | _string \| Array \| object_ | - |
| overlayStyle | 自定义遮罩层样式 | _object_ | - |
Expand Down Expand Up @@ -204,6 +205,7 @@ Vant 中导出了以下 Dialog 相关的辅助函数:
| cancel-button-text | 取消按钮文案 | _string_ | `取消` |
| cancel-button-color | 取消按钮颜色 | _string_ | `black` |
| cancel-button-disabled | 是否禁用取消按钮 | _boolean_ | `false` |
| destroy-on-close `v4.9.18` | 是否在关闭时销毁内容 | _boolean_ | `false` |
| z-index | 将弹窗的 z-index 层级设置为一个固定值 | _number \| string_ | `2000+` |
| overlay | 是否展示遮罩层 | _boolean_ | `true` |
| overlay-class | 自定义遮罩层类名 | _string_ | - |
Expand Down
1 change: 1 addition & 0 deletions packages/vant/src/dialog/function-call.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const DEFAULT_OPTIONS = {
showCancelButton: false,
closeOnPopstate: true,
closeOnClickOverlay: false,
destroyOnClose: false,
} as const;

let currentOptions = extend({}, DEFAULT_OPTIONS);
Expand Down

0 comments on commit 1e390af

Please sign in to comment.