diff --git a/src/components/SidebarMobile/SidebarMobile.jsx b/src/components/SidebarMobile/SidebarMobile.jsx index dd9077fe09c4..812f01b1c9c8 100644 --- a/src/components/SidebarMobile/SidebarMobile.jsx +++ b/src/components/SidebarMobile/SidebarMobile.jsx @@ -18,9 +18,24 @@ export default class SidebarMobile extends Component { sections: PropTypes.array, }; + componentDidMount() { + if (this.props.isOpen) { + this._toggleBodyListener(true); + } + } + + componentDidUpdate(prevProps) { + if (prevProps.isOpen !== this.props.isOpen) { + this._toggleBodyListener(this.props.isOpen); + } + } + + componentWillUnmount() { + this._toggleBodyListener(false); + } + render() { const { isOpen, toggle } = this.props; - this._toggleBodyListener(isOpen); return (