Improve modal flow and back button handling (#16499)
* Refactor shouldUpdateScroll passing So far, shouldUpdateScroll has been manually passed down from the very top of the React component hierarchy even though it is a static function common to all ScrollContainer instances, so replaced that with a custom class extending ScrollContainer. * Generalize “press back to close modal” to any modal and to public pages * Fix boost confirmation modal closing media modal
This commit is contained in:
		@@ -20,8 +20,6 @@ const messages = defineMessages({
 | 
			
		||||
  next: { id: 'lightbox.next', defaultMessage: 'Next' },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export const previewState = 'previewMediaModal';
 | 
			
		||||
 | 
			
		||||
export default @injectIntl
 | 
			
		||||
class MediaModal extends ImmutablePureComponent {
 | 
			
		||||
 | 
			
		||||
@@ -37,10 +35,6 @@ class MediaModal extends ImmutablePureComponent {
 | 
			
		||||
    volume: PropTypes.number,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  static contextTypes = {
 | 
			
		||||
    router: PropTypes.object,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  state = {
 | 
			
		||||
    index: null,
 | 
			
		||||
    navigationHidden: false,
 | 
			
		||||
@@ -98,16 +92,6 @@ class MediaModal extends ImmutablePureComponent {
 | 
			
		||||
  componentDidMount () {
 | 
			
		||||
    window.addEventListener('keydown', this.handleKeyDown, false);
 | 
			
		||||
 | 
			
		||||
    if (this.context.router) {
 | 
			
		||||
      const history = this.context.router.history;
 | 
			
		||||
 | 
			
		||||
      history.push(history.location.pathname, previewState);
 | 
			
		||||
 | 
			
		||||
      this.unlistenHistory = history.listen(() => {
 | 
			
		||||
        this.props.onClose();
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this._sendBackgroundColor();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -131,14 +115,6 @@ class MediaModal extends ImmutablePureComponent {
 | 
			
		||||
  componentWillUnmount () {
 | 
			
		||||
    window.removeEventListener('keydown', this.handleKeyDown);
 | 
			
		||||
 | 
			
		||||
    if (this.context.router) {
 | 
			
		||||
      this.unlistenHistory();
 | 
			
		||||
 | 
			
		||||
      if (this.context.router.history.location.state === previewState) {
 | 
			
		||||
        this.context.router.history.goBack();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.props.onChangeBackgroundColor(null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user