Making WordPress.org

Opened 11 years ago

Closed 4 years ago

Last modified 4 years ago

#155 closed enhancement (fixed)

Confirm page close when writing on WordPress.org forums

Reported by: daedalon's profile Daedalon Owned by: dd32's profile dd32
Milestone: Q1 Priority: normal
Component: Support Forums Keywords: has-patch
Cc:

Description

Migrating from #wp24145:

When writing on WordPress.org forums, sometimes long and well thought-out replies are lost due to accidental page closing. This causes countless amounts of work lost within the WordPress community.

There should be a confirmation dialog to prevent accidental page closing after user has entered something in the new post form.

Comments in #wp24145 have a jQuery-based solution if we want to use it.

Attachments (1)

155.patch (1.1 KB) - added by denisco 4 years ago.

Download all attachments as: .zip

Change History (9)

#1 @Daedalon
11 years ago

  • Keywords has-patch dev-feedback added

Here's an improved solution based on the earlier one in #wp24145 and comments in Stack Overflow. Uses addEventListener to avoid overriding other listeners and includes a workaround for clients that don't support it.

if( $('#postform').length ){
    requireConfirmClose = false;
    $('#postform input[type=text], #postform select, #postform textarea').change( function(){
    	requireConfirmClose = true;
    });
    $('input#postformsub').click( function(){
        requireConfirmClose = false;
    });
    // Workaround for browsers without addEventListener support
    if (typeof window.addEventListener === 'undefined') {
        window.addEventListener = function(e, callback) {
            return window.attachEvent('on' + e, callback);
        }
    }
    window.addEventListener('beforeunload', function(eventObject) {
        if ( requireConfirmClose ) {
            eventObject.returnValue = 'Are you sure you want to close this page? All changes will be lost.';
        }
    });
}

This ticket was mentioned in Slack in #forums by clorith. View the logs.


6 years ago

#3 @Clorith
6 years ago

  • Keywords needs-patch added; has-patch dev-feedback removed
  • Priority changed from lowest to normal

Definitely a feature that would improve UX, and is fairly simple to implement. We are likely losing out on topics from users who can't be bothered re-typing after accidentally leaving.

#4 @tellyworth
5 years ago

  • Milestone set to Q1

@denisco
4 years ago

#5 @denisco
4 years ago

  • Keywords has-patch added; needs-patch removed

#6 @dd32
4 years ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 9602:

Support Forums: Confirm before leaving a page when a reply/thread has been started but not submitted.

Props denisco.
Fixes #155.

#7 @dd32
4 years ago

  • Milestone changed from Q1 to 2020 Q1

Milestone renamed

#8 @dd32
4 years ago

  • Milestone changed from 2020 Q1 to Q1

Milestone renamed

Note: See TracTickets for help on using tickets.