Page MenuHomePhabricator

EditWarning script warns about leaving a page that is not changed
Closed, ResolvedPublic

Description

Steps:

  1. Enable EditWarning script (UsabilityInitiative/EditWarning/EditWarning.js).
  2. Enable preview upon first edit.
  3. Edit any page.
  4. Attempt to close it without any changes.

The problem is that the script checks if the preview element is available, but it should be checking whether the action is "submit". That is:
Check if the current values of some form elements are the same as
the original values
if(
wgAction == 'submit'

$j( '#wpSummary' ).data( 'origtext' ) != $j( '#wpSummary' ).val()
$j( '#wpTextbox1' ).data( 'origtext' ) != $j( '#wpTextbox1' ).val()

) {
...

Rather then currently used:
Check if the current values of some form elements are the same as
the original values
if(
$j( '#wpTextbox1' ).data( 'origtext' ) != $j( '#wpTextbox1' ).val()

$j( '#wpSummary' ).data( 'origtext' ) != $j( '#wpSummary' ).val()
$j( '#wikiPreview' ).is( ':visible' )

) {
...

BTW. The order of checks is intentional - the check of origtext and wpTextbox1 val is potentially the most time (CPU) consuming and therefore the script should rule out other options first.


Version: unspecified
Severity: major

Details

Reference
bz21682

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:54 PM
bzimport set Reference to bz21682.
bzimport added a subscriber: Unknown Object (MLST).