diff --git a/app/javascript/mastodon/components/modal_root.jsx b/app/javascript/mastodon/components/modal_root.jsx index 1eae0819af7..61ff19256f8 100644 --- a/app/javascript/mastodon/components/modal_root.jsx +++ b/app/javascript/mastodon/components/modal_root.jsx @@ -61,14 +61,6 @@ class ModalRoot extends PureComponent { this.history = this.props.history || createBrowserHistory(); } - UNSAFE_componentWillReceiveProps (nextProps) { - if (!!nextProps.children && !this.props.children) { - this.activeElement = document.activeElement; - - this.getSiblings().forEach(sibling => sibling.setAttribute('inert', true)); - } - } - componentDidUpdate (prevProps) { if (!this.props.children && !!prevProps.children) { this.getSiblings().forEach(sibling => sibling.removeAttribute('inert')); @@ -85,9 +77,15 @@ class ModalRoot extends PureComponent { this._handleModalClose(); } + if (this.props.children && !prevProps.children) { + this.activeElement = document.activeElement; + + this.getSiblings().forEach(sibling => sibling.setAttribute('inert', true)); + this._handleModalOpen(); } + if (this.props.children) { this._ensureHistoryBuffer(); }