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
- Click Add files
- Select files
- Do not click "Start upload"
- 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
c2370f393d394c54b5d66900466091f9eec731ddthere is no submit handler bound to the form - on the previous commit
b59bb32c364203acd69ddce403f6d0fdec71bb8cthere 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
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:
- 3416594-no-longer-uploads-on-submit
changes, plain diff MR !13
Comments
Comment #4
budalokko commentedThanks 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
Comment #5
ericgsmith commentedTested MR and it resolves the issue - thank you! Has test coverage to ❤️
Comment #8
budalokko commented