From 21f0419ace9d256240516f953d33b335068b9706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AF=B8=E5=B2=B3?= Date: Thu, 10 Jan 2019 01:21:51 +0800 Subject: [PATCH] feat: Add mask prop for Modal method, close #14177 (#14197) --- components/modal/Modal.tsx | 1 + components/modal/__tests__/confirm.test.js | 5 +++++ components/modal/confirm.tsx | 2 ++ components/modal/index.en-US.md | 1 + components/modal/index.zh-CN.md | 1 + 5 files changed, 10 insertions(+) diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 484a659171..dffc222496 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -79,6 +79,7 @@ export interface ModalFuncProps { icon?: React.ReactNode; /* Deperated */ iconType?: string; + mask?: boolean; maskClosable?: boolean; zIndex?: number; okCancel?: boolean; diff --git a/components/modal/__tests__/confirm.test.js b/components/modal/__tests__/confirm.test.js index ca12e90d3a..86c9430d1f 100644 --- a/components/modal/__tests__/confirm.test.js +++ b/components/modal/__tests__/confirm.test.js @@ -168,4 +168,9 @@ describe('Modal.confirm triggers callbacks correctly', () => { expect($$('.custom-modal-confirm')).toHaveLength(1); expect($$('.custom-modal-confirm-body-wrapper')).toHaveLength(1); }); + + it('should be Modal.confirm without mask', () => { + open({ mask: false }); + expect($$('.ant-modal-mask')).toHaveLength(0); + }); }); diff --git a/components/modal/confirm.tsx b/components/modal/confirm.tsx index 914308b78c..4fc42b3ca9 100644 --- a/components/modal/confirm.tsx +++ b/components/modal/confirm.tsx @@ -43,6 +43,7 @@ const ConfirmDialog = (props: ConfirmDialogProps) => { const okCancel = 'okCancel' in props ? props.okCancel! : true; const width = props.width || 416; const style = props.style || {}; + const mask = props.mask === undefined ? true : props.mask; // 默认为 false,保持旧版默认行为 const maskClosable = props.maskClosable === undefined ? false : props.maskClosable; const runtimeLocale = getConfirmLocale(); @@ -80,6 +81,7 @@ const ConfirmDialog = (props: ConfirmDialogProps) => { transitionName="zoom" footer="" maskTransitionName="fade" + mask={mask} maskClosable={maskClosable} maskStyle={maskStyle} style={style} diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md index ad97b9e868..d60d0a1096 100644 --- a/components/modal/index.en-US.md +++ b/components/modal/index.en-US.md @@ -71,6 +71,7 @@ The properties of the object are follows: | icon | custom icon (`Added in 3.12.0`) | string\|ReactNode | `` | | iconType | Icon `type` of the Icon component (deperated after `3.12.0`) | string | `question-circle` | | keyboard | Whether support press esc to close | Boolean | true | +| mask | Whether show mask or not. | Boolean | true | | maskClosable | Whether to close the modal dialog when the mask (area outside the modal) is clicked | Boolean | `false` | | okText | Text of the OK button | string | `OK` | | okType | Button `type` of the OK button | string | `primary` | diff --git a/components/modal/index.zh-CN.md b/components/modal/index.zh-CN.md index ad64c41a3e..69993b8dd3 100644 --- a/components/modal/index.zh-CN.md +++ b/components/modal/index.zh-CN.md @@ -69,6 +69,7 @@ title: Modal | content | 内容 | string\|ReactNode | 无 | | icon | 自定义图标(3.12.0 新增) | string\|ReactNode | `` | | iconType | 图标类型(3.12.0 后废弃,请使用 `icon`) | string | `question-circle` | +| mask | 是否展示遮罩 | Boolean | true | | maskClosable | 点击蒙层是否允许关闭 | Boolean | `false` | | okText | 确认按钮文字 | string | 确定 | | okType | 确认按钮类型 | string | primary |