Skip to content

Commit

Permalink
Fixed #7242 - File Question - An empty preview appears when the onDow…
Browse files Browse the repository at this point in the history
…nloadFiles event returns with the options.callback('error')
  • Loading branch information
tsv2013 committed Nov 7, 2023
1 parent 004b949 commit eedf9c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/question_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,9 @@ export class QuestionFileModel extends Question {
if (this.survey) {
this.survey.uploadFiles(this, this.name, files, (status, data) => {
if (status === "error") {
this.errors.push(new UploadingFileError(data, this));
this.stateChanged("error");
this.stateChanged("loaded");
}
if (status === "success") {
this.value = (this.value || []).concat(
Expand Down
8 changes: 5 additions & 3 deletions tests/questionFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ QUnit.test(
})
);
} else {
options.callback("error");
options.callback("error", "custom error text");
}
}, 1);
});
Expand All @@ -504,8 +504,10 @@ QUnit.test(
setTimeout(() => {
assert.ok(q1.isEmpty());
assert.equal(q1.value, undefined);
assert.equal(stateSec, "->loading->error");
assert.equal(state, "error");
assert.equal(stateSec, "->loading->error->loaded");
assert.equal(q1.errors.length, 1, "Has errors");
assert.equal(q1.errors[0].text, "custom error text", "Error text");
assert.equal(state, "loaded");
done();

isSuccess = true;
Expand Down

0 comments on commit eedf9c8

Please sign in to comment.