Skip to content

Commit

Permalink
fix(comp:modal): update modal content with update doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Nov 10, 2022
1 parent 99e4ddd commit 0d0518b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/components/modal/src/ModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineComponent({

return () => {
const prefixCls = `${mergedPrefixCls.value}-body`
const defaultNode = slots.default?.()
const defaultNode = slots.default?.() ?? props.__content_node

if (isDefault.value) {
return <div class={prefixCls}>{defaultNode}</div>
Expand Down
6 changes: 1 addition & 5 deletions packages/components/modal/src/ModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ export default defineComponent({
const mergedProps = { key, visible, ref: setRef, 'onUpdate:visible': onUpdateVisible, onAfterClose }

const contentNode = isVNode(content) ? cloneVNode(content, contentProps, true) : content
return (
<Modal {...mergedProps} {...restProps}>
{contentNode}
</Modal>
)
return <Modal {...mergedProps} {...restProps} __content_node={contentNode} />
})
return (
<>
Expand Down
3 changes: 3 additions & 0 deletions packages/components/modal/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export const modalProps = {
onClose: [Function, Array] as PropType<MaybeArray<(evt?: Event | unknown) => void>>,
onCancel: [Function, Array] as PropType<MaybeArray<(evt?: Event | unknown) => unknown>>,
onOk: [Function, Array] as PropType<MaybeArray<(evt?: Event | unknown) => unknown>>,

// private
__content_node: [String, Object] as PropType<string | VNode>,
} as const

export type ModalProps = ExtractInnerPropTypes<typeof modalProps>
Expand Down

0 comments on commit 0d0518b

Please sign in to comment.