From 2ee51057529ce93109e0530ebefda916e073315b Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sat, 18 Jun 2016 15:46:00 +0300 Subject: [PATCH] #140: do not close popup on overlay click, if a dropdown menu is active --- src/components/ui/form/Dropdown.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ui/form/Dropdown.jsx b/src/components/ui/form/Dropdown.jsx index fb69e93..37edbf5 100644 --- a/src/components/ui/form/Dropdown.jsx +++ b/src/components/ui/form/Dropdown.jsx @@ -38,7 +38,9 @@ export default class Dropdown extends FormInputComponent { }; componentDidMount() { - document.addEventListener('click', this.onBodyClick); + // listen to capturing phase to ensure, that our event handler will be + // called before all other + document.addEventListener('click', this.onBodyClick, true); } componentWillUnmount() { @@ -129,6 +131,7 @@ export default class Dropdown extends FormInputComponent { if (!el.contains(event.target) && el !== event.taget) { event.preventDefault(); + event.stopPropagation(); this.toggle(); }