From 1f7f5fe4f3787beabd4d39232e36ea2571971a12 Mon Sep 17 00:00:00 2001 From: myronliu347 Date: Thu, 22 Nov 2018 14:12:42 +0800 Subject: [PATCH 1/2] fix(Message): When there are multiple Message, the first can't close --- src/message/toast.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/message/toast.jsx b/src/message/toast.jsx index df15d3559c..6c8eb6947d 100644 --- a/src/message/toast.jsx +++ b/src/message/toast.jsx @@ -101,7 +101,13 @@ const create = props => { const newContext = ConfigProvider.getContext(); - let mask, myRef; + let mask, myRef, destroyed = false; + const destroy = () => { + const inc = mask && mask.getInstance(); + inc && inc.handleClose(true); + destroyed = true; + }; + ReactDOM.render( { @@ -110,14 +116,14 @@ const create = props => { , div, function() { mask = myRef; + if (mask && destroyed) { + destroy(); + } }); return { component: mask, - destroy: () => { - const inc = mask && mask.getInstance(); - inc && inc.handleClose(true); - } + destroy }; }; From c721069e6a837515781f579740278c2d002777e0 Mon Sep 17 00:00:00 2001 From: myronliu347 Date: Fri, 23 Nov 2018 17:53:43 +0800 Subject: [PATCH 2/2] test(Cascader): fix test unit --- test/cascader/index-spec.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/test/cascader/index-spec.js b/test/cascader/index-spec.js index 0429951bd4..06055048f5 100644 --- a/test/cascader/index-spec.js +++ b/test/cascader/index-spec.js @@ -41,14 +41,14 @@ describe('Cascader', () => { let wrapper; afterEach(() => { - const overlay = document.querySelectorAll('.next-overlay-wrapper'); - overlay.forEach(dom => { - document.body.removeChild(dom); - }); - if (wrapper) { - wrapper.unmount(); - wrapper = null; - } + const overlay = document.querySelectorAll('.next-overlay-wrapper'); + overlay.forEach(dom => { + document.body.removeChild(dom); + }); + if (wrapper) { + wrapper.unmount(); + wrapper = null; + } }); it('should render single cascader', () => { @@ -60,12 +60,16 @@ describe('Cascader', () => { changeCalled = true; assert(v === '2980'); delete d.children; + delete d._source; assert.deepEqual(d, { value: '2980', label: '铜川', pos: '0-0-1' }); - e.selectedPath.forEach(d => delete d.children); + e.selectedPath.forEach(d => { + delete d.children; + delete d._source; + }); assert.deepEqual(e, { selectedPath: [{ value: '2973', @@ -100,12 +104,16 @@ describe('Cascader', () => { changeCalled = true; assert(v === '2980'); delete d.children; + delete d._source; assert.deepEqual(d, { value: '2980', label: '铜川', pos: '0-0-1' }); - e.selectedPath.forEach(d => delete d.children); + e.selectedPath.forEach(d => { + delete d.children; + delete d._source; + }); assert.deepEqual(e, { selectedPath: [{ value: '2973', @@ -208,6 +216,8 @@ describe('Cascader', () => { let data; let extra; const handleChange = (v, d, e) => { + d.forEach(d => delete d._source); + e.checkedData.forEach(d => delete d._source); assert.deepEqual(value, sortByValue(v, true)); assert.deepEqual(data, sortByValue(d)); e.checkedData = sortByValue(e.checkedData); @@ -270,6 +280,8 @@ describe('Cascader', () => { let data; let extra; const handleChange = (v, d, e) => { + d.forEach(d => delete d._source); + e.checkedData.forEach(d => delete d._source); assert.deepEqual(value, sortByValue(v, true)); assert.deepEqual(data, sortByValue(d)); e.checkedData = sortByValue(e.checkedData);