From c930ca80d383d0a34cb95e295ff5f714187ceb89 Mon Sep 17 00:00:00 2001 From: Manasvi Agrawal Date: Tue, 23 Jun 2026 12:37:25 +0530 Subject: [PATCH] fix: set accept attribute on file input for acrobat feedback screen --- .../workflow-acrobat/action-binder.test.js | 24 +++++++++++++++++++ .../workflow-acrobat/action-binder.js | 3 +++ 2 files changed, 27 insertions(+) diff --git a/test/core/workflow/workflow-acrobat/action-binder.test.js b/test/core/workflow/workflow-acrobat/action-binder.test.js index 42580a77..062e088c 100644 --- a/test/core/workflow/workflow-acrobat/action-binder.test.js +++ b/test/core/workflow/workflow-acrobat/action-binder.test.js @@ -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'; diff --git a/unitylibs/core/workflow/workflow-acrobat/action-binder.js b/unitylibs/core/workflow/workflow-acrobat/action-binder.js index aba5413f..e9b1656e 100644 --- a/unitylibs/core/workflow/workflow-acrobat/action-binder.js +++ b/unitylibs/core/workflow/workflow-acrobat/action-binder.js @@ -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');