Skip to content

Commit

Permalink
Merge pull request #12345 from calixteman/save_btn
Browse files Browse the repository at this point in the history
Don't try to save something for a button which is neither a checkbox nor a radio
  • Loading branch information
brendandahl authored Sep 8, 2020
2 parents 68b99c5 + 7e5026d commit e51e9d1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,8 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
return this._saveRadioButton(evaluator, task, annotationStorage);
}

return super.save(evaluator, task, annotationStorage);
// Nothing to save
return null;
}

async _saveCheckbox(evaluator, task, annotationStorage) {
Expand Down
23 changes: 23 additions & 0 deletions test/unit/annotation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,29 @@ describe("annotation", function () {
done();
}, done.fail);
});

it("should save nothing", function (done) {
const buttonWidgetRef = Ref.get(124, 0);
const xref = new XRefMock([
{ ref: buttonWidgetRef, data: buttonWidgetDict },
]);
const task = new WorkerTask("test save");

AnnotationFactory.create(
xref,
buttonWidgetRef,
pdfManagerMock,
idFactoryMock
)
.then(annotation => {
return annotation.save(partialEvaluator, task, {});
})
.then(data => {
expect(data).toEqual(null);
done();
})
.catch(done.fail);
});
});

describe("ChoiceWidgetAnnotation", function () {
Expand Down

0 comments on commit e51e9d1

Please sign in to comment.