From 3effd6dbdb505c65b5ea0bb860ba177657be2cc3 Mon Sep 17 00:00:00 2001 From: sveisvei Date: Mon, 5 Dec 2016 17:10:32 +0100 Subject: [PATCH] close drawer on new page --- frontend/src/component/app.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/src/component/app.jsx b/frontend/src/component/app.jsx index 8dc7818601..a1722fdd38 100644 --- a/frontend/src/component/app.jsx +++ b/frontend/src/component/app.jsx @@ -42,6 +42,20 @@ export default class App extends Component { document.title = `${this.getCurrentSection()} - Unleash Admin`; } + componentWillReceiveProps (nextProps) { + // copied from https://github.com/react-mdl/react-mdl/issues/254 + // If our locations are different and drawer is open, + // force a close + if (this.props.location.pathname !== nextProps.location.pathname) { + const layout = document.querySelector('.mdl-js-layout'); + const drawer = document.querySelector('.mdl-layout__drawer'); + + if (layout.classList.contains('is-small-screen') && drawer.classList.contains('is-visible')) { + layout.MaterialLayout.toggleDrawer(); + } + } + } + getCurrentSection () { const { routes } = this.props; const lastRoute = routes[routes.length - 1];