From a19f32b03cfaa1a24acb3c21f486462edb2c2b13 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 21 May 2017 18:04:02 +0300 Subject: [PATCH] native receive dropdown outside click --- react/src/components/dashboard/walletsData.js | 2 -- .../dashboard/walletsNativeReceive.js | 18 ++++++++++++++++++ .../dashboard/walletsNativeSyncProgress.js | 2 +- .../dashboard/walletsNativeTxHistory.js | 3 ++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index b316667..9dcb4e0 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -70,8 +70,6 @@ class WalletsData extends React.Component { } handleClickOutside(e) { - console.log(e); - if (e.srcElement.className !== 'btn dropdown-toggle btn-info' && (e.srcElement.offsetParent && e.srcElement.offsetParent.className !== 'btn dropdown-toggle btn-info') && (e.path && e.path[4] && e.path[4].className.indexOf('showkmdwalletaddrs') === -1) && diff --git a/react/src/components/dashboard/walletsNativeReceive.js b/react/src/components/dashboard/walletsNativeReceive.js index 2216ec5..bf1371d 100644 --- a/react/src/components/dashboard/walletsNativeReceive.js +++ b/react/src/components/dashboard/walletsNativeReceive.js @@ -16,6 +16,24 @@ class WalletsNativeReceive extends React.Component { openDropMenu: false, }; this.openDropMenu = this.openDropMenu.bind(this); + this.handleClickOutside = this.handleClickOutside.bind(this); + } + + componentWillMount() { + document.addEventListener('click', this.handleClickOutside, false); + } + + componentWillUnmount() { + document.removeEventListener('click', this.handleClickOutside, false); + } + + handleClickOutside(e) { + if (e.srcElement.className.indexOf('dropdown') === -1 && + (e.srcElement.offsetParent && e.srcElement.offsetParent.className.indexOf('dropdown') === -1)) { + this.setState({ + openDropMenu: false, + }); + } } openDropMenu() { diff --git a/react/src/components/dashboard/walletsNativeSyncProgress.js b/react/src/components/dashboard/walletsNativeSyncProgress.js index 50942fc..d13c538 100644 --- a/react/src/components/dashboard/walletsNativeSyncProgress.js +++ b/react/src/components/dashboard/walletsNativeSyncProgress.js @@ -29,7 +29,7 @@ class WalletsNativeSyncProgress extends React.Component { ); } else { - var syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0); + const syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0); return (