[Glitch] Compensate for scrollbar disappearing when media modal

Port 60df87f6f0 to glitch-soc
This commit is contained in:
Thibaut Girka
2018-07-31 23:04:09 +02:00
parent d2b3eebe00
commit 175c2155a9
4 changed files with 24 additions and 21 deletions

View File

@ -45,14 +45,15 @@ export default class ModalRoot extends React.PureComponent {
};
getSnapshotBeforeUpdate () {
const visible = !!this.props.type;
return {
overflowY: visible ? 'hidden' : null,
};
return { visible: !!this.props.type };
}
componentDidUpdate (prevProps, prevState, { overflowY }) {
document.body.style.overflowY = overflowY;
componentDidUpdate (prevProps, prevState, { visible }) {
if (visible) {
document.body.classList.add('with-modals--active');
} else {
document.body.classList.remove('with-modals--active');
}
}
renderLoading = modalId => () => {