Page MenuHomePhabricator

PageForms saves form only after two clicks on "Save page" button if VEforAll is used
Closed, ResolvedPublicBUG REPORT

Description

This is a follow on from task T278567 where this issue was reported previously.

T278567 added a fix in this change after I reopened the task: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/747925/

However, it turns out that this was previously fixed in this change: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/739566. I did not know this, and was using an older version of Page Forms (5.2.1) which did not include this fix.

Unfortunately it looks like the two changes are incompatible, and T278567 has broken the save button again:

// Interrupt "Save page" and "Show changes" actions
// var $formButtons = $( '#wpSave, #wpDiff' );
var $formButtons = $( 'button[name="wpSave"], button[name="wpDiff"]' ); // <-- first change 739566
var canSubmit = false;

if ( $formButtons.length > 0 ) {
        $formButtons.each( function ( i, button ) {
                $( button ).on( 'click', function ( event ) {
                        if ( !canSubmit ) {
                                event.preventDefault();
                                mw.pageFormsActualizeVisualEditorFields( function () {
                                        canSubmit = true;
                                        // $( button ).find("[type='submit']").click();
                                        $( button ).find("[type='submit']").click();        // <-- second change T278567
                                } );
                        }
                } );
        } );
}

The first change made it so $formButtons selects the actual submit buttons (instead of the span elements), which on its own fixes the issue. The second change triggers the click event on a child element of $( button ) with type=submit, which on its own also fixes the issue.

Unfortunately, taking both of the fixes together breaks the Save button again. $( button ) is the submit button already, and it is not possible to find a child element with type=submit anymore.

I would suggest reverting T278567 to resolve this.

My apologies for reopening T278567 in the first place a few weeks ago. I should have tested this on the latest version of Page Forms.

List of steps to reproduce (step by step, including full links if applicable):

  • Edit with form and click "Save Page"

What happens?:

  • Need to click "Save Page" twice for the page to actually save

What should have happened instead?:

  • Single click on the button should be sufficient

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:

  • Page Forms 5.3.2