From cf223f7d6571cf6714fd1fe124797ec08a0ac6a7 Mon Sep 17 00:00:00 2001 From: Erik Dev Date: Mon, 24 Apr 2023 13:19:49 +0300 Subject: [PATCH 1/2] =?UTF-8?q?[fixed]:1015=20-=20Fixed=20incorrect=20beha?= =?UTF-8?q?vior=20when=20you=20need=20to=20click=20twice=20on=20the=20over?= =?UTF-8?q?lay=20to=20close=20modal=20window=20if=20you=20click=20on=20som?= =?UTF-8?q?ething=20with=20event.stopPropagation()=20inside=20content=20bl?= =?UTF-8?q?ock.=20-=20Wrote=20a=20test=20case=20for=20closing=20modal=20by?= =?UTF-8?q?=20click=20on=20the=20overlay=20after=20click=20on=20something?= =?UTF-8?q?=20placed=C2=A0=20inside=20modal=20and=20containing=20stopPropa?= =?UTF-8?q?gation=20for=20the=20"click"=20event.=20Fixed=20test=20cases=20?= =?UTF-8?q?for=20the=20overlay=20MD=20->=20content=20MU=20&&=20content=20M?= =?UTF-8?q?D=20->=20overlay=20MU=20cases.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- specs/Modal.events.spec.js | 32 ++++++++++++++++++++++++++++++++ src/components/ModalPortal.js | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/specs/Modal.events.spec.js b/specs/Modal.events.spec.js index 8c9d5f2b..9c9a9bab 100644 --- a/specs/Modal.events.spec.js +++ b/specs/Modal.events.spec.js @@ -222,6 +222,7 @@ export default () => { withModal(props, null, modal => { mouseDownAt(moverlay(modal)); mouseUpAt(mcontent(modal)); + clickAt(mcontent(modal)); requestCloseCallback.called.should.not.be.ok(); }); }); @@ -236,9 +237,40 @@ export default () => { withModal(props, null, modal => { mouseDownAt(mcontent(modal)); mouseUpAt(moverlay(modal)); + clickAt(moverlay(modal)); requestCloseCallback.called.should.not.be.ok(); }); }); + + it("click on button containing stopPropagation inside modal shouldn't block closing", () => { + const requestCloseCallback = sinon.spy(); + let innerButton = null; + let innerButtonRef = ref => { + innerButton = ref; + }; + function click(event) { + event.stopPropagation(); + } + + withModal( + { + isOpen: true, + onRequestClose: requestCloseCallback + }, +