From 41b7e8dc2cc1122f98846743f2de814dfa4bee2b Mon Sep 17 00:00:00 2001 From: Josh Kruder Date: Tue, 7 Jul 2015 16:54:35 -0400 Subject: [PATCH] Fix issue where Overlay can prevent the entire body from scrolling when it is unmounted. --- src/overlay.jsx | 12 ++++++++---- src/snackbar.jsx | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/overlay.jsx b/src/overlay.jsx index 106247ef91143b..18b627a277e5ce 100644 --- a/src/overlay.jsx +++ b/src/overlay.jsx @@ -6,6 +6,8 @@ let Colors = require('./styles/colors'); let Overlay = React.createClass({ + _originalBodyOverflow: '', + mixins: [StylePropable], propTypes: { @@ -21,13 +23,16 @@ let Overlay = React.createClass({ }; }, + componentDidMount() { + this._originalBodyOverflow = document.getElementsByTagName('body')[0].style.oveflow; + }, + componentDidUpdate() { if (this.props.autoLockScrolling) (this.props.show) ? this._preventScrolling() : this._allowScrolling(); }, - componentWillUnmount() { - this.allowScrolling(); + this._allowScrolling(); }, setOpacity(opacity) { @@ -70,7 +75,6 @@ let Overlay = React.createClass({ }, render() { - let { show, style, @@ -99,7 +103,7 @@ let Overlay = React.createClass({ _allowScrolling() { let body = document.getElementsByTagName('body')[0]; - body.style.overflow = ''; + body.style.overflow = this._originalBodyOverflow; } }); diff --git a/src/snackbar.jsx b/src/snackbar.jsx index 3f6cffde3d7a34..51de5f943760ce 100644 --- a/src/snackbar.jsx +++ b/src/snackbar.jsx @@ -13,7 +13,7 @@ let Snackbar = React.createClass({ manuallyBindClickAway: true, // ID of the active timer. - autoHideTimerId: undefined, + _autoHideTimerId: undefined, contextTypes: { muiTheme: React.PropTypes.object @@ -143,15 +143,15 @@ let Snackbar = React.createClass({ }, _clearAutoHideTimer() { - if (this.autoHideTimerId !== undefined) { - this.autoHideTimerId = clearTimeout(this.autoHideTimerId); + if (this._autoHideTimerId !== undefined) { + this._autoHideTimerId = clearTimeout(this._autoHideTimerId); } }, _setAutoHideTimer() { if (this.props.autoHideDuration > 0) { this._clearAutoHideTimer(); - this.autoHideTimerId = setTimeout(() => { this.dismiss(); }, this.props.autoHideDuration); + this._autoHideTimerId = setTimeout(() => { this.dismiss(); }, this.props.autoHideDuration); } }