Skip to content

Commit 83f7c6e

Browse files
committed
fix: modal afterClose trigger twice
1 parent 2cbc72f commit 83f7c6e

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

components/_util/PortalWrapper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import PropTypes from './vue-types';
22
import switchScrollingEffect from './switchScrollingEffect';
33
import setStyle from './setStyle';
44
import Portal from './Portal';
5+
import syncWatch from './syncWatch';
56

67
let openCount = 0;
78
const windowIsUndefined = !(
@@ -32,9 +33,9 @@ export default {
3233
this.setWrapperClassName();
3334
},
3435
watch: {
35-
visible(val) {
36+
visible: syncWatch(function(val) {
3637
openCount = val ? openCount + 1 : openCount - 1;
37-
},
38+
}),
3839
getContainer(getContainer, prevGetContainer) {
3940
const getContainerIsFunc =
4041
typeof getContainer === 'function' && typeof prevGetContainer === 'function';

components/modal/Modal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const ButtonType = buttonTypes().type;
1111
import LocaleReceiver from '../locale-provider/LocaleReceiver';
1212
import { initDefaultProps, getComponent, getSlot } from '../_util/props-util';
1313
import { ConfigConsumerProps } from '../config-provider';
14+
import syncWatch from '../_util/syncWatch';
1415

1516
let mousePosition = null;
1617
// ref: https://github.com/ant-design/ant-design/issues/15795
@@ -106,9 +107,9 @@ export default {
106107
};
107108
},
108109
watch: {
109-
visible(val) {
110+
visible: syncWatch(function(val) {
110111
this.sVisible = val;
111-
},
112+
}),
112113
},
113114
setup() {
114115
return {

components/vc-dialog/Dialog.jsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export default {
6565
}),
6666
data() {
6767
return {
68-
destroyPopup: false,
6968
inTransition: false,
7069
titleId: `rcDialogTitle${uuid++}`,
7170
dialogMouseDown: undefined,
@@ -74,9 +73,6 @@ export default {
7473

7574
watch: {
7675
visible(val) {
77-
if (val) {
78-
this.destroyPopup = false;
79-
}
8076
this.$nextTick(() => {
8177
this.updatedCallback(!val);
8278
});
@@ -147,15 +143,12 @@ export default {
147143
}
148144
},
149145
onAnimateLeave() {
150-
const { afterClose, destroyOnClose } = this;
146+
const { afterClose } = this;
151147
// need demo?
152148
// https://github.com/react-component/dialog/pull/28
153149
if (this.$refs.wrap) {
154150
this.$refs.wrap.style.display = 'none';
155151
}
156-
if (destroyOnClose) {
157-
this.destroyPopup = true;
158-
}
159152
this.inTransition = false;
160153
this.switchScrollingEffect();
161154
if (afterClose) {
@@ -295,7 +288,7 @@ export default {
295288
});
296289
return (
297290
<Transition key="dialog" {...dialogTransitionProps}>
298-
{visible || !this.destroyPopup ? dialogElement : null}
291+
{visible || !this.destroyOnClose ? dialogElement : null}
299292
</Transition>
300293
);
301294
},

examples/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Use Drawer to quickly preview details of an object, such as those in a list.
1515
</div>
1616
</template>
1717
<script>
18-
import demo from '../antdv-demo/docs/carousel/demo';
18+
import demo from '../antdv-demo/docs/modal/demo';
1919
export default {
2020
components: {
2121
demo,

0 commit comments

Comments
 (0)