From c854e9d5b2db99b1855351d163191f1c23a199fb Mon Sep 17 00:00:00 2001 From: yangjinjun3 <475473228@qq.com> Date: Fri, 15 Apr 2022 16:15:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DDialog=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=85=B3=E9=97=AD=E4=BA=8B=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E6=B8=85=E9=99=A4body=E6=A0=B7=E5=BC=8F=E7=B1=BB=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/dialog/DialogWrapper.tsx | 8 ++++++- src/packages/dialog/dialog.tsx | 30 ++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/packages/dialog/DialogWrapper.tsx b/src/packages/dialog/DialogWrapper.tsx index a8a5f9084c..9c3d564afb 100644 --- a/src/packages/dialog/DialogWrapper.tsx +++ b/src/packages/dialog/DialogWrapper.tsx @@ -5,12 +5,18 @@ interface DialogWrapperProps { visible?: boolean title?: ReactNode footer?: ReactNode + lockScroll?: boolean + onCancel?: Function + onClosed?: Function } export const DialogWrapper: FunctionComponent< Partial & HTMLAttributes > = (props) => { - const { visible } = props + const { visible, lockScroll } = props + if (lockScroll && !visible && document.body.classList.value.includes('nut-overflow-hidden')) { + document.body.classList.remove('nut-overflow-hidden') + } return (
diff --git a/src/packages/dialog/dialog.tsx b/src/packages/dialog/dialog.tsx index ccad82b569..992252baa8 100644 --- a/src/packages/dialog/dialog.tsx +++ b/src/packages/dialog/dialog.tsx @@ -24,12 +24,23 @@ const BaseDialog: ForwardRefRenderFunction< unknown, Partial & HTMLAttributes > = (props, ref) => { - const { visible, footer, noOkBtn, noCancelBtn, okBtnDisabled, cancelAutoClose, ...restProps } = - props + const { + visible, + footer, + noOkBtn, + noCancelBtn, + lockScroll, + okBtnDisabled, + cancelAutoClose, + okText, + cancelText, + onClosed, + onCancel, + onOk, + ...restProps + } = props const renderFooter = () => { - const { okText, cancelText, footer, lockScroll, onClosed, onCancel, onOk } = props - if (footer === null) return const handleCancel = (e?: any) => { @@ -80,7 +91,16 @@ const BaseDialog: ForwardRefRenderFunction< return footerContent } - return + return ( + + ) } export const Dialog: DialogComponent = forwardRef(BaseDialog) as DialogComponent From 090f48fe471405c02efc4deeee03c1104e6abf0a Mon Sep 17 00:00:00 2001 From: yangjinjun3 <475473228@qq.com> Date: Mon, 18 Apr 2022 11:30:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9onCancel&onClosed?= =?UTF-8?q?=E7=9A=84TS=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/dialog/DialogWrap.tsx | 4 ++-- src/packages/dialog/DialogWrapper.tsx | 4 ++-- src/packages/dialog/config.ts | 2 +- src/packages/dialog/doc.md | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/packages/dialog/DialogWrap.tsx b/src/packages/dialog/DialogWrap.tsx index c7e880267d..9898807483 100644 --- a/src/packages/dialog/DialogWrap.tsx +++ b/src/packages/dialog/DialogWrap.tsx @@ -9,8 +9,8 @@ interface DialogWrapProps { mask?: boolean lockScroll?: boolean closeOnClickOverlay?: boolean - onCancel?: Function - onClosed?: Function + onCancel?: () => void + onClosed?: () => void } export const DialogWrap: FunctionComponent< diff --git a/src/packages/dialog/DialogWrapper.tsx b/src/packages/dialog/DialogWrapper.tsx index 9c3d564afb..0b120e9c4b 100644 --- a/src/packages/dialog/DialogWrapper.tsx +++ b/src/packages/dialog/DialogWrapper.tsx @@ -6,8 +6,8 @@ interface DialogWrapperProps { title?: ReactNode footer?: ReactNode lockScroll?: boolean - onCancel?: Function - onClosed?: Function + onCancel?: () => void + onClosed?: () => void } export const DialogWrapper: FunctionComponent< diff --git a/src/packages/dialog/config.ts b/src/packages/dialog/config.ts index 7803570f33..61a7c5c4d7 100644 --- a/src/packages/dialog/config.ts +++ b/src/packages/dialog/config.ts @@ -24,7 +24,7 @@ export interface DialogProps { textAlign?: any footerDirection?: string lockScroll?: boolean - onClosed?: Function + onClosed?: () => void onOk?: (e?: MouseEvent) => Promise | void onCancel?: () => void onConfirm?: (e?: MouseEvent) => Promise | void diff --git a/src/packages/dialog/doc.md b/src/packages/dialog/doc.md index 29607c5bbb..97d94d6656 100644 --- a/src/packages/dialog/doc.md +++ b/src/packages/dialog/doc.md @@ -105,4 +105,4 @@ return <> |--------|----------------|--------------| | onOk | 确定按钮回调 | (e?: MouseEvent) => Promise | void | | onCancel | 取消按钮回调 | () => void | -| onClosed | 关闭回调,任何情况关闭弹窗都会触发 | Function | +| onClosed | 关闭回调,任何情况关闭弹窗都会触发 | () => void |