Skip to content

Commit

Permalink
Fix for error on cancelling uploader. Added support for clear error b…
Browse files Browse the repository at this point in the history
…utton (not visible by default) on errors.
  • Loading branch information
anthonyjb committed Nov 23, 2019
1 parent 2813e5b commit c4c78f3
Show file tree
Hide file tree
Showing 4 changed files with 2,252 additions and 2,237 deletions.
13 changes: 13 additions & 0 deletions module/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,19 @@ export class FileField {
this._error = new ErrorMessage(this.field)
this._error.init(message)

// Add clear handler
$.listen(
this._error.error,
{
'clear': () => {

// Clear the error
this.clearError()

}
}
)

// Add the error CSS modifier to the field
this.field.classList.add(this.constructor.css['hasError'])
}
Expand Down
4 changes: 3 additions & 1 deletion module/ui/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ export class Uploader {
this._handlers = {

'cancel': (event) => {
const uploader = this.uploader

// Abort the upload
event.preventDefault()
if (this._xhr) {
this._xhr.abort()
}

// Dispatch a cancelled event against the uploader
$.dispatch(this.uploader, 'cancelled')
$.dispatch(uploader, 'cancelled')
},

'reqAbort': (event) => {
Expand Down
Loading

0 comments on commit c4c78f3

Please sign in to comment.