From acbc6158b86161ae48aa47ca4c7b9f5106f45c72 Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Thu, 29 Aug 2019 22:50:53 +0800
Subject: [PATCH] update dialog to 7.5.5
---
components/_util/switchScrollingEffect.js | 6 +-
components/_util/warning.js | 6 +-
components/config-provider/index.jsx | 1 -
.../__snapshots__/Modal.test.js.snap | 18 +--
components/vc-dialog/Dialog.jsx | 149 ++++++++++--------
components/vc-dialog/IDialogPropTypes.js | 4 +-
components/vc-dialog/LazyRenderBox.jsx | 2 +-
components/vc-dialog/demo/ant-design.vue | 17 +-
components/vc-dialog/index.js | 2 +-
9 files changed, 114 insertions(+), 91 deletions(-)
diff --git a/components/_util/switchScrollingEffect.js b/components/_util/switchScrollingEffect.js
index ff2301b76..5346c80a7 100644
--- a/components/_util/switchScrollingEffect.js
+++ b/components/_util/switchScrollingEffect.js
@@ -1,8 +1,8 @@
import getScrollBarSize from './getScrollBarSize';
-export default (close) => {
- const bodyIsOverflowing = document.body.scrollHeight >
- (window.innerHeight || document.documentElement.clientHeight) &&
+export default close => {
+ const bodyIsOverflowing =
+ document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) &&
window.innerWidth > document.body.offsetWidth;
if (!bodyIsOverflowing) {
return;
diff --git a/components/_util/warning.js b/components/_util/warning.js
index 10f61831f..b76fce037 100644
--- a/components/_util/warning.js
+++ b/components/_util/warning.js
@@ -19,11 +19,7 @@ export function resetWarned() {
warned = {};
}
-export function call(
- method,
- valid,
- message,
-) {
+export function call(method, valid, message) {
if (!valid && !warned[message]) {
method(false, message);
warned[message] = true;
diff --git a/components/config-provider/index.jsx b/components/config-provider/index.jsx
index aa4dcc3f2..6ccec05ac 100644
--- a/components/config-provider/index.jsx
+++ b/components/config-provider/index.jsx
@@ -14,7 +14,6 @@ function getWatch(keys = []) {
return watch;
}
-
const ConfigProvider = {
name: 'AConfigProvider',
props: {
diff --git a/components/modal/__tests__/__snapshots__/Modal.test.js.snap b/components/modal/__tests__/__snapshots__/Modal.test.js.snap
index 640e48e4d..6c9b4ad1d 100644
--- a/components/modal/__tests__/__snapshots__/Modal.test.js.snap
+++ b/components/modal/__tests__/__snapshots__/Modal.test.js.snap
@@ -8,14 +8,14 @@ exports[`Modal render correctly 1`] = `
@@ -33,14 +33,14 @@ exports[`Modal render correctly 2`] = `
@@ -58,11 +58,11 @@ exports[`Modal render without footer 1`] = `
diff --git a/components/vc-dialog/Dialog.jsx b/components/vc-dialog/Dialog.jsx
index cc6cfcf94..fda773f74 100644
--- a/components/vc-dialog/Dialog.jsx
+++ b/components/vc-dialog/Dialog.jsx
@@ -1,15 +1,14 @@
-import { getComponentFromProp } from '../_util/props-util';
+import { getComponentFromProp, initDefaultProps } from '../_util/props-util';
import KeyCode from '../_util/KeyCode';
import contains from '../_util/Dom/contains';
import LazyRenderBox from './LazyRenderBox';
import BaseMixin from '../_util/BaseMixin';
import getTransitionProps from '../_util/getTransitionProps';
-import getScrollBarSize from '../_util/getScrollBarSize';
+import switchScrollingEffect from '../_util/switchScrollingEffect';
import getDialogPropTypes from './IDialogPropTypes';
const IDialogPropTypes = getDialogPropTypes();
let uuid = 0;
-let openCount = 0;
/* eslint react/no-is-mounted:0 */
function noop() {}
@@ -46,23 +45,19 @@ function offset(el) {
pos.top += getScroll(w, true);
return pos;
}
-const initDefaultProps = (propTypes, defaultProps) => {
- return Object.keys(defaultProps).map(k => propTypes[k].def(defaultProps[k]));
-};
+
export default {
mixins: [BaseMixin],
- props: {
- ...IDialogPropTypes,
- ...initDefaultProps(IDialogPropTypes, {
- mask: true,
- visible: false,
- keyboard: true,
- closable: true,
- maskClosable: true,
- destroyOnClose: false,
- prefixCls: 'rc-dialog',
- }),
- },
+ props: initDefaultProps(IDialogPropTypes, {
+ mask: true,
+ visible: false,
+ keyboard: true,
+ closable: true,
+ maskClosable: true,
+ destroyOnClose: false,
+ prefixCls: 'rc-dialog',
+ getOpenCount: () => null,
+ }),
data() {
return {
destroyPopup: false,
@@ -97,12 +92,18 @@ export default {
mounted() {
this.$nextTick(() => {
this.updatedCallback(false);
+ // if forceRender is true, set element style display to be none;
+ if ((this.forceRender || (this.getContainer === false && !this.visible)) && this.$refs.wrap) {
+ this.$refs.wrap.style.display = 'none';
+ }
});
},
beforeDestroy() {
- if (this.visible || this.inTransition) {
+ const { visible, getOpenCount } = this;
+ if ((visible || this.inTransition) && !getOpenCount()) {
this.removeScrollingEffect();
}
+ clearTimeout(this.timeoutId);
},
methods: {
updatedCallback(visible) {
@@ -160,12 +161,23 @@ export default {
afterClose();
}
},
+ onDialogMouseDown() {
+ this.dialogMouseDown = true;
+ },
+
+ onMaskMouseUp() {
+ if (this.dialogMouseDown) {
+ this.timeoutId = setTimeout(() => {
+ this.dialogMouseDown = false;
+ }, 0);
+ }
+ },
onMaskClick(e) {
// android trigger click on open (fastclick??)
if (Date.now() - this.openTime < 300) {
return;
}
- if (e.target === e.currentTarget) {
+ if (e.target === e.currentTarget && !this.dialogMouseDown) {
this.close(e);
}
},
@@ -236,6 +248,7 @@ export default {
const closeIcon = getComponentFromProp(this, 'closeIcon');
closer = (