From 4314cebb06736398eedc675906324d6e5cd53011 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 27 Jun 2016 20:11:52 -0700 Subject: [PATCH] Fix(map): prevent map drawer from opening on map route --- common/app/App.jsx | 12 +++++++++--- common/app/components/Nav/Nav.jsx | 7 ++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/common/app/App.jsx b/common/app/App.jsx index 307f9e9044..9e336e2dd8 100644 --- a/common/app/App.jsx +++ b/common/app/App.jsx @@ -60,7 +60,9 @@ const bindableActions = { // export plain class for testing export class FreeCodeCamp extends React.Component { static displayName = 'FreeCodeCamp'; - + static contextTypes = { + router: PropTypes.object + }; static propTypes = { children: PropTypes.node, username: PropTypes.string, @@ -77,7 +79,8 @@ export class FreeCodeCamp extends React.Component { toggleMapDrawer: PropTypes.func, toggleMainChat: PropTypes.func, fetchUser: PropTypes.func, - shouldShowSignIn: PropTypes.bool + shouldShowSignIn: PropTypes.bool, + params: PropTypes.object }; componentWillReceiveProps({ @@ -135,6 +138,7 @@ export class FreeCodeCamp extends React.Component { } render() { + const { router } = this.context; const { username, points, @@ -144,9 +148,11 @@ export class FreeCodeCamp extends React.Component { isMapAlreadyLoaded, toggleMapDrawer, toggleMainChat, - shouldShowSignIn + shouldShowSignIn, + params: { lang } } = this.props; const navProps = { + isOnMap: router.isActive(`/${lang}/map`), username, points, picture, diff --git a/common/app/components/Nav/Nav.jsx b/common/app/components/Nav/Nav.jsx index bb13d5a810..28f89102a3 100644 --- a/common/app/components/Nav/Nav.jsx +++ b/common/app/components/Nav/Nav.jsx @@ -32,14 +32,12 @@ const toggleButtonChild = ( export default class extends React.Component { static displayName = 'Nav'; - static contextTypes = { - router: PropTypes.object - }; static propTypes = { points: PropTypes.number, picture: PropTypes.string, signedIn: PropTypes.bool, username: PropTypes.string, + isOnMap: PropTypes.bool, updateNavHeight: PropTypes.func, toggleMapDrawer: PropTypes.func, toggleMainChat: PropTypes.func, @@ -184,12 +182,11 @@ export default class extends React.Component { username, points, picture, + isOnMap, toggleMapDrawer, toggleMainChat, shouldShowSignIn } = this.props; - const { router } = this.context; - const isOnMap = router.isActive('/map'); return (