MudFileUpload: fix AppendMultipleFiles keeping stale file references (#9586)#9600
Conversation
|
It could be possible to test against this by playing around with Need to do a bunch of regression testing for this since it messes with multiple HTML inputs. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #9600 +/- ##
==========================================
+ Coverage 89.82% 90.80% +0.97%
==========================================
Files 412 406 -6
Lines 11878 12830 +952
Branches 2364 2485 +121
==========================================
+ Hits 10670 11650 +980
+ Misses 681 625 -56
- Partials 527 555 +28 ☔ View full report in Codecov by Sentry. |
|
Can't test against the actual bug with bUnit since it's a browser error (in JS). Will do more manual regression testing before publishing the PR. |
|
Ready for review. I will do some more some manual testing on all browsers today to make sure I didn't miss any edge cases. |
Mr-Technician
left a comment
There was a problem hiding this comment.
LGTM pending the one change
|
@henon should be this moved to v8 or this breaking change is fine? |
|
Let's play this safe and release it with v8. This is not urgent is it? And we have decided to start the v8 process now anyway, so it won't be long. |
|
Nope not urgent, I prefer playing it safe too, thanks! |
|
Do we merge this in v8? @henon |
|
Yes! Thanks @igotinfected |
|
@igotinfected What would you say we should write in the migration guide about this? |
(The fix description) (The breaking change description) ... or something similar! |
|
So what should people do who rely on that id? What workaround can we propose to them? |
|
Hmm I can't think of a scenario where you would absolutely need the id of the underlying input other than for automated UI testing purposes. You could use a different selector instead, for example by adding your own custom attribute like @* razor code *@
<MudFileUpload data-test-id="my-test-id" ...// UI test code
var inputs = document.querySelectorAll('[data-test-id="my-test-id"]');
var activeInput = inputs[inputs.length - 1];
...We can probably mess around with the |
|
Thanks, I think this explanation is enough. People can find it when they follow the link to this issue. |
|
Added to the v8 migration guide at #9953 |
MudBlazor#9586) (MudBlazor#9600) Co-authored-by: Artyom M. <artem.melnikov@live.com>
|
I did update to version MudBlazor 7.15.0 through nuget package but error still persist, anything i should do? |
This will only be available with v8, you could try it out with one of the released v8 previews in the meantime! |
Description
Resolves #9586
Resolves #9795
Fixed an issue where uploading files multiple times with AppendMultipleFiles and attempting to read the file contents would throw an exception indicating that those files no longer exist.
Problem explained in #9586 (comment).
Whats it boils down to is that when using
AppendMultipleFilesinMudFileUploadwe append "new" files to our list of "old" files. The references to old files however no longer exist in the HTML input, causing an error when trying to read those files.Currently users have to disable
AppendMultipleFilesand make use of the file references with every upload.The fix proposed here consists creating new
InputFileinstances with every upload, so that the previous file references are retained. This implementation implies the following:inputcontrols in HTML, each with their uniqueidinputis "active" at a timeinputs are destroyed afterClearAsyncis calledids since we now have multipleinputs at once (This also fixes an issue where the
FilesChangedcallback would not be triggered when uploading the same file twice (despite the file contents having changed) (#9795).How Has This Been Tested?
Visually with test components and with some basic unit tests.
Type of Changes
Checklist
dev).