Problem/Motivation

Starting from version 2.1.0-rc1 it appears the widget no longer uploads when the form is submitted.

I have a form with the plupload field type, and previously if I select the files, I can upload them when the form is submitted.

In 2.1.0 I get an error "File upload is required" when submitting the form.

The workaround is to click "Upload files" before submitting the form.

It appears to be related to commit c2370f393d394c54b5d66900466091f9eec731dd

Steps to reproduce

On a form with a plupload widget

  1. Click Add files
  2. Select files
  3. Do not click "Start upload"
  4. Submit the form

c2370f393d394c54b5d66900466091f9eec731dd introduced a few changes for code formatting - but I think some of the changes have introduced errors when converting to arrow function expressions which do not have their own binding to this.

Inspecting the form I can see:

  • on c2370f393d394c54b5d66900466091f9eec731dd there is no submit handler bound to the form
  • on the previous commit b59bb32c364203acd69ddce403f6d0fdec71bb8c there is a submit handler bound to the form

On c2370f393d394c54b5d66900466091f9eec731dd if I put a breakpoint on the following line:

if ($(this).find('.plupload-element').length > 0) {

And inspect the this variable I see

this
Object { attach: attach(context, settings) }

But the following lines are expecting this to be the form, as shown in the previous commit.

On the previous commit b59bb32c364203acd69ddce403f6d0fdec71bb8c if I put a breakpoint on the line:

if (0 < $(this).find('.plupload-element').length) {

And inspect the this variable I see

this
<form id="....

Proposed resolution

Fix the JS

Remaining tasks

  • Patch
  • Review
  • Test
  • Commit

Issue fork plupload-3416594

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ericgsmith created an issue. See original summary.

budalokko made their first commit to this issue’s fork.

budalokko’s picture

Status: Active » Needs review

Thanks for the detailed bug report !! There was too much refactoring to pass those eslint tests :)

Can you try the patch in the MR? It's this one:

https://git.drupalcode.org/project/plupload/-/merge_requests/13.diff

ericgsmith’s picture

Status: Needs review » Reviewed & tested by the community

Tested MR and it resolves the issue - thank you! Has test coverage to ❤️

msgph changed the visibility of the branch 3416594-no-longer-uploads-on-submit to hidden.

  • budalokko committed a6a0e391 on 2.1.x
    Issue #3416594 by budalokko, ericgsmith: Plupload widget no longer...
budalokko’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.