Check if router is injected in media modal (#7941)
parent
4ebdff6e25
commit
df5b46f1b0
|
@ -67,19 +67,23 @@ export default class MediaModal extends ImmutablePureComponent {
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
window.addEventListener('keyup', this.handleKeyUp, false);
|
window.addEventListener('keyup', this.handleKeyUp, false);
|
||||||
const history = this.context.router.history;
|
if (this.context.router) {
|
||||||
history.push(history.location.pathname, previewState);
|
const history = this.context.router.history;
|
||||||
this.unlistenHistory = history.listen(() => {
|
history.push(history.location.pathname, previewState);
|
||||||
this.props.onClose();
|
this.unlistenHistory = history.listen(() => {
|
||||||
});
|
this.props.onClose();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
window.removeEventListener('keyup', this.handleKeyUp);
|
window.removeEventListener('keyup', this.handleKeyUp);
|
||||||
this.unlistenHistory();
|
if (this.context.router) {
|
||||||
|
this.unlistenHistory();
|
||||||
|
|
||||||
if (this.context.router.history.location.state === previewState) {
|
if (this.context.router.history.location.state === previewState) {
|
||||||
this.context.router.history.goBack();
|
this.context.router.history.goBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue