Replace unsafe willReceiveProps in modal_root

This commit is contained in:
diondiondion 2025-11-20 16:16:10 +01:00
parent 461d267574
commit 28a9492e53

View File

@ -61,14 +61,6 @@ class ModalRoot extends PureComponent {
this.history = this.props.history || createBrowserHistory(); 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) { componentDidUpdate (prevProps) {
if (!this.props.children && !!prevProps.children) { if (!this.props.children && !!prevProps.children) {
this.getSiblings().forEach(sibling => sibling.removeAttribute('inert')); this.getSiblings().forEach(sibling => sibling.removeAttribute('inert'));
@ -85,9 +77,15 @@ class ModalRoot extends PureComponent {
this._handleModalClose(); this._handleModalClose();
} }
if (this.props.children && !prevProps.children) { if (this.props.children && !prevProps.children) {
this.activeElement = document.activeElement;
this.getSiblings().forEach(sibling => sibling.setAttribute('inert', true));
this._handleModalOpen(); this._handleModalOpen();
} }
if (this.props.children) { if (this.props.children) {
this._ensureHistoryBuffer(); this._ensureHistoryBuffer();
} }