Skip to content

FORMS-26813 : Show custom acceptMessage for unsupported file type in File Attachment - #1943

Merged
mayankjindalmj merged 3 commits into
devfrom
FORMS-26813-fileinput-accept-message-dev
Aug 4, 2026
Merged

FORMS-26813 : Show custom acceptMessage for unsupported file type in File Attachment#1943
mayankjindalmj merged 3 commits into
devfrom
FORMS-26813-fileinput-accept-message-dev

Conversation

@mayankjindalmj

@mayankjindalmj mayankjindalmj commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The file-input widget's invalidMessage() looked up constraintMessages.invalidMimeType for the "unsupported file type" alert, but invalidMimeType is not an authorable constraint message key — the schema only exposes constraintMessages.accept (backed by the acceptMessage dialog property, see AbstractBaseImpl.ConstraintMessages#getAcceptConstraintMessage).
  • As a result, the custom message authors configure for file-type validation was always ignored in favor of the generic fallback string, while the analogous maxFileSize custom message worked correctly since its key matched (constraintMessages.maxFileSize).
  • Fixed in both the webpack source (ui.frontend/src/view/FormFileInputWidgetBase.js) and the apps clientlib copy (ui.af.apps/.../fileinput/v4/fileinput/clientlibs/site/js/fileinputwidget.js).

Root cause (reproduced live)

File uploaded Alert before fix Alert after fix
Oversized file (allowed type) Custom maxFileSize message ✅ unchanged ✅
Unsupported file type Generic fallback message ❌ (ignored author's acceptMessage) Custom accept/acceptMessage text ✅

Test plan

  • node --check on both modified JS files
  • Added Cypress test should display a custom error message configured by the user for unsupported file type in fileinputv4.runtime.cy.js, mirroring the existing maxFileSize custom-message test
  • Added acceptMessage to the fileinput7 fixture field in the IT sample content used by that spec
  • Full Cypress IT run against a live AEM instance (not run in this environment — no AEM instance available)

…n file input

The file-input widget's invalidMessage() looked up
constraintMessages.invalidMimeType for the unsupported-file-type alert,
but invalidMimeType is not an authorable constraint message key - the
schema only exposes constraintMessages.accept (backed by the
acceptMessage dialog property). As a result the custom message
authors configure for file type validation was always ignored in
favor of the generic fallback string, while the analogous
maxFileSize custom message worked correctly since its key matched.

Updated both the webpack source (ui.frontend) and the apps clientlib
copy (ui.af.apps) to read constraintMessages.accept, and added a
Cypress assertion mirroring the existing maxFileSize custom-message
test.
@mayankjindalmj
mayankjindalmj marked this pull request as ready for review August 3, 2026 06:16
Mayank Jindal and others added 2 commits August 3, 2026 16:33
…t reaches the mime-type (accept) check instead of the empty-file check

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nsupported-type test

Point the accept test at fileinput3 (accept=[application/pdf]) and upload sample.svg
(an image, unsupported there) instead of populating a sample.afe placeholder. svg is
non-empty so it passes the empty-file check and reaches the mime-type (accept) check.
Matches the release/650 backport (#1940).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
page-has-heading-one moderate
target-size serious

3 similar comments
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
page-has-heading-one moderate
target-size serious

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
page-has-heading-one moderate
target-size serious

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
page-has-heading-one moderate
target-size serious

@mayankjindalmj
mayankjindalmj merged commit 590591f into dev Aug 4, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants