[Bug] Preloader doesn't ensure order of showing or hiding
- Dominant language
- TypeScript
- Stars
- 285
- Forks
- 307
- PR merge metrics
- No merged PRs in 30d
Description
### How to reproduce the bug in a custom uploader:
```js
uploader: {
uploadByFile(file) {
return new Promise((resolve, reject) => {
// e.g. checking file size, almost synchronous
// Pass a file with a size larger than 1024 (1kb)
if (file.size > 1024) {
resolve({ success: 0 });
} else {
// ... go on
}
});
},
}
```
In this case, Preloader is meaninglessly being hidden first by `hidePreloader` following `uploadingFailed`,
then shown up by `showPreloader` following `FileReader.onload` (because it takes longer than the previous one)
As a result, Preloader keeps appearing **despite uploading process is already over**.
### How to fix the bug:
Promisify `FileReader` and do upload after awaiting `FileReader.onload`
I'll send a pull request including the fix commits about this issue.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.