Plupload widget no longer uploads on submit

Created on 23 January 2024, 10 months ago
Updated 16 March 2024, 8 months ago

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
🐛 Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

🇳🇿New Zealand ericgsmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024