Skip to content

Commit

Permalink
Fix #1480: Correct preview content setting after validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Dec 13, 2019
1 parent ee58364 commit 333da5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Change Log: `bootstrap-fileinput`
- (bug #1499, #1502): Correct duplicate file check error rendering.
- (enh #1497): Better validation of progress display when `showPreview` is `false`.
- (bug #1482): Validate `initialPreviewShowDelete` setting correctly.
- (bug #1480): Correct preview content setting after validation error.

## version 5.0.7

Expand Down
11 changes: 8 additions & 3 deletions js/fileinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@
if (!$h.isArray(content)) {
content = content.split(self.initialPreviewDelimiter);
}
if (append) {
if (append && data.content && data.content.length) {
index = data.content.push(content[0]) - 1;
data.config[index] = config;
data.tags[index] = tags;
Expand Down Expand Up @@ -2057,7 +2057,12 @@
var self = this, label = self.minFileCount > 1 ? self.filePlural : self.fileSingle,
msg = self.msgFilesTooLess.replace('{n}', self.minFileCount).replace('{files}', label),
$error = self.$errorContainer;
self._addError(msg);
msg = '<li>' + msg + '</li>';
if ($error.find('ul').length === 0) {
self._addError('<ul>' + msg + '</ul>');
} else {
$error.find('ul').append(msg);
}
self.isError = true;
self._updateFileDetails(0);
$error.fadeIn(self.fadeDelay);
Expand Down Expand Up @@ -4868,7 +4873,7 @@
}
if (self.isAjaxUpload) {
self._raise('filebatchselected', [fm.stack]);
if (fm.count() === 0) {
if (fm.count() === 0 && !self.isError) {
self.reset();
}
} else {
Expand Down
Loading

0 comments on commit 333da5e

Please sign in to comment.