diff --git a/components/overlay/Overlay.js b/components/overlay/Overlay.js index 4bbe0990..5c54e8aa 100644 --- a/components/overlay/Overlay.js +++ b/components/overlay/Overlay.js @@ -33,7 +33,7 @@ class Overlay extends Component { componentWillUpdate (nextProps) { if (nextProps.active && !this.props.active) document.body.style.overflow = 'hidden'; - if (!nextProps.active && this.props.active) document.body.style.overflow = ''; + if (!nextProps.active && this.props.active && !document.querySelectorAll('[data-react-toolbox="overlay"]')[1]) document.body.style.overflow = ''; } componentDidUpdate () { @@ -43,7 +43,7 @@ class Overlay extends Component { } componentWillUnmount () { - document.body.style.overflow = ''; + if (!document.querySelectorAll('[data-react-toolbox="overlay"]')[1]) document.body.style.overflow = ''; if (this.escKeyListener) { document.body.removeEventListener('keydown', this.handleEscKey); this.escKeyListener = null; @@ -65,7 +65,7 @@ class Overlay extends Component { return ( -
+
{children}
diff --git a/lib/overlay/Overlay.js b/lib/overlay/Overlay.js index 0bf6de75..f5662715 100644 --- a/lib/overlay/Overlay.js +++ b/lib/overlay/Overlay.js @@ -39,7 +39,7 @@ var Overlay = function (_Component) { function Overlay() { _classCallCheck(this, Overlay); - return _possibleConstructorReturn(this, Object.getPrototypeOf(Overlay).apply(this, arguments)); + return _possibleConstructorReturn(this, (Overlay.__proto__ || Object.getPrototypeOf(Overlay)).apply(this, arguments)); } _createClass(Overlay, [{ @@ -54,7 +54,7 @@ var Overlay = function (_Component) { key: 'componentWillUpdate', value: function componentWillUpdate(nextProps) { if (nextProps.active && !this.props.active) document.body.style.overflow = 'hidden'; - if (!nextProps.active && this.props.active) document.body.style.overflow = null; + if (!nextProps.active && this.props.active && !document.querySelectorAll('[data-react-toolbox="overlay"]')[1]) document.body.style.overflow = ''; } }, { key: 'componentDidUpdate', @@ -66,7 +66,7 @@ var Overlay = function (_Component) { }, { key: 'componentWillUnmount', value: function componentWillUnmount() { - document.body.style.overflow = null; + if (!document.querySelectorAll('[data-react-toolbox="overlay"]')[1]) document.body.style.overflow = ''; if (this.escKeyListener) { document.body.removeEventListener('keydown', this.handleEscKey); this.escKeyListener = null; @@ -99,7 +99,7 @@ var Overlay = function (_Component) { null, _react2.default.createElement( 'div', - { className: _className }, + { className: _className, 'data-react-toolbox': 'overlay' }, _react2.default.createElement('div', { className: theme.backdrop, onClick: onClick }), children )