Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions test/core/workflow/workflow-acrobat/action-binder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,30 @@ describe('ActionBinder', () => {
extractSpy.restore();
});

it('should set accept attribute on input when allowedFileTypes is populated', async () => {
const el = document.createElement('input');
el.type = 'file';
const block = { querySelector: sinon.stub().returns(el) };
const actMap = { input: 'upload' };
actionBinder.limits = { allowedFileTypes: ['application/illustrator', 'application/x-indesign'] };

await actionBinder.initActionListeners(block, actMap);

expect(el.getAttribute('accept')).to.equal('application/illustrator,application/x-indesign');
});

it('should not set accept attribute on input when allowedFileTypes is empty', async () => {
const el = document.createElement('input');
el.type = 'file';
const block = { querySelector: sinon.stub().returns(el) };
const actMap = { input: 'upload' };
actionBinder.limits = { allowedFileTypes: [] };

await actionBinder.initActionListeners(block, actMap);

expect(el.getAttribute('accept')).to.be.null;
});

it('should handle input change event with multiple files', async () => {
const el = document.createElement('input');
el.type = 'file';
Expand Down
3 changes: 3 additions & 0 deletions unitylibs/core/workflow/workflow-acrobat/action-binder.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,9 @@ export default class ActionBinder {
break;
}
case el.nodeName === 'INPUT':
if (this.limits.allowedFileTypes?.length) {
el.setAttribute('accept', this.limits.allowedFileTypes.join(','));
}
el.addEventListener('change', async (e) => {
const { files, totalFileSize } = this.extractFiles(e);
await this.acrobatActionMaps(value, files, totalFileSize, 'change');
Expand Down
Loading