Skip to content

Forms 18927 allow extensions support in file input #1586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from

Conversation

rajatofficial
Copy link
Contributor

No description provided.

@rajatofficial rajatofficial changed the base branch from master to dev May 7, 2025 05:07
Copy link

codecov bot commented May 7, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.34%. Comparing base (1ec18f1) to head (c10b1e9).

Files with missing lines Patch % Lines
...q/forms/core/components/models/form/FileInput.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #1586      +/-   ##
============================================
+ Coverage     82.32%   82.34%   +0.01%     
- Complexity     1000     1004       +4     
============================================
  Files           108      108              
  Lines          2603     2611       +8     
  Branches        370      371       +1     
============================================
+ Hits           2143     2150       +7     
- Misses          272      273       +1     
  Partials        188      188              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rajatofficial rajatofficial force-pushed the FORMS-18927-AllowExtensionsSupportInFileInput branch from 920a278 to c10b1e9 Compare May 7, 2025 09:46
@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 96 75

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 94 96 96 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

2 similar comments
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

mimeTypeField.find('coral-multifield-item:not(:first)').remove();

// Set value of first item to */*
firstItem.find('input').val('*/*');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this "firstItem.find('input').val('/');" means all mimetypes are allowed or ignored?

}

if(mimeTypeFieldInfoIcon.length > 0) {
// show the info icon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Info icon should be present by default, not based on condition

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajatofficial To confirm - this is need because it is behind FT?

isInvalidFileName = isCurrentInvalidFileName = true;
inValidNamefileNames = currFileName + "," + inValidNamefileNames;
} else {
// Now size is in MB
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajatofficial why this formatting change - the previous one looks correct..


// Disable the entire multifield and its contents
mimeTypeField.css({
'pointer-events': hasExtensions ? 'none' : 'auto',
Copy link
Collaborator

@nit23uec nit23uec May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls manage css by adding relevant classes rather inside the js itself.

mimeTypeField.prop('disabled', hasExtensions);

// Disable delete icons and their SVGs
mimeTypeField.find('coral-icon[icon="delete"], ._coral-Icon--svg').css({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything that starts with a underscore is an internal coral selector. We should not use any coral internals in the code.

// If no first item exists, create one
if (firstItem.length === 0) {
// Click the add button to create a new item
mimeTypeField.find('button[coral-multifield-add]').click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than simulating clicks we should be using add API for Multi field.

});

// Handle MIME type items if extensions exist
if (hasExtensions) {
Copy link
Collaborator

@nit23uec nit23uec May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not immediately clear from this code that what, why and when do we intend to do this
Is it just to reset the mimetype with just 1 item whose value is */* whenever extensions exist/added? Im suspecting it's due to avoidance of gng into complexities wrt conflict in server side validation. Am I correct?

@@ -123,6 +123,7 @@ private ReservedProperties() {
public static final String PN_UNCHECKED_VALUE = "uncheckedValue";
public static final String PN_MAX_FILE_SIZE = "maxFileSize";
public static final String PN_FILE_ACCEPT = "accept";
public static final String PN_FILE_ACCEPT_EXTENSIONS = "acceptExtensions";
Copy link
Collaborator

@nit23uec nit23uec May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any new prop persisted in jcr should being with fd:

let hasExtensions = extensionsField.find('coral-multifield-item').length > 0;
if (hasExtensions) {
mimeTypeField.css({
'pointer-events': 'none',
Copy link
Collaborator

@nit23uec nit23uec May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Html5 file accept allows mimetypes and extensions to be set simultaneously. is there any specific reason for this otherwise behavior in our component?

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.

None yet

6 participants