Fix missing beforeUnload confirmation when a poll is being authored (#36030)
				
					
				
			This commit is contained in:
		@@ -90,8 +90,7 @@ const messages = defineMessages({
 | 
			
		||||
const mapStateToProps = state => ({
 | 
			
		||||
  layout: state.getIn(['meta', 'layout']),
 | 
			
		||||
  isComposing: state.getIn(['compose', 'is_composing']),
 | 
			
		||||
  hasComposingText: state.getIn(['compose', 'text']).trim().length !== 0,
 | 
			
		||||
  hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0,
 | 
			
		||||
  hasComposingContents: state.getIn(['compose', 'text']).trim().length !== 0 || state.getIn(['compose', 'media_attachments']).size > 0 || state.getIn(['compose', 'poll']) !== null,
 | 
			
		||||
  canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < state.getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments']),
 | 
			
		||||
  firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION,
 | 
			
		||||
  newAccount: !state.getIn(['accounts', me, 'note']) && !state.getIn(['accounts', me, 'bot']) && state.getIn(['accounts', me, 'following_count'], 0) === 0 && state.getIn(['accounts', me, 'statuses_count'], 0) === 0,
 | 
			
		||||
@@ -272,8 +271,7 @@ class UI extends PureComponent {
 | 
			
		||||
    dispatch: PropTypes.func.isRequired,
 | 
			
		||||
    children: PropTypes.node,
 | 
			
		||||
    isComposing: PropTypes.bool,
 | 
			
		||||
    hasComposingText: PropTypes.bool,
 | 
			
		||||
    hasMediaAttachments: PropTypes.bool,
 | 
			
		||||
    hasComposingContents: PropTypes.bool,
 | 
			
		||||
    canUploadMore: PropTypes.bool,
 | 
			
		||||
    intl: PropTypes.object.isRequired,
 | 
			
		||||
    layout: PropTypes.string.isRequired,
 | 
			
		||||
@@ -288,11 +286,11 @@ class UI extends PureComponent {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  handleBeforeUnload = e => {
 | 
			
		||||
    const { intl, dispatch, isComposing, hasComposingText, hasMediaAttachments } = this.props;
 | 
			
		||||
    const { intl, dispatch, isComposing, hasComposingContents } = this.props;
 | 
			
		||||
 | 
			
		||||
    dispatch(synchronouslySubmitMarkers());
 | 
			
		||||
 | 
			
		||||
    if (isComposing && (hasComposingText || hasMediaAttachments)) {
 | 
			
		||||
    if (isComposing && hasComposingContents) {
 | 
			
		||||
      e.preventDefault();
 | 
			
		||||
      // Setting returnValue to any string causes confirmation dialog.
 | 
			
		||||
      // Many browsers no longer display this text to users,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user