Skip to content

Commit

Permalink
fix(comp:modal): update modal content with update doesn't work (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Nov 15, 2022
1 parent 6082a15 commit 38f130a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 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
5 changes: 4 additions & 1 deletion packages/components/modal/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ 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>
export type ModalPublicProps = ExtractPublicPropTypes<typeof modalProps>
export type ModalPublicProps = Omit<ExtractPublicPropTypes<typeof modalProps>, '__content_node'>
export interface ModalBindings {
open: () => void
close: (evt?: Event | unknown) => Promise<void>
Expand Down

0 comments on commit 38f130a

Please sign in to comment.