Skip to content

USWDS - File Input - Add ability to use custom error message when wrong file type is used for file-input.js#3890

Merged
thisisdano merged 4 commits into
uswds:developfrom
hilvitzs:file-upload-custom-message
Sep 20, 2021
Merged

USWDS - File Input - Add ability to use custom error message when wrong file type is used for file-input.js#3890
thisisdano merged 4 commits into
uswds:developfrom
hilvitzs:file-upload-custom-message

Conversation

@hilvitzs

@hilvitzs hilvitzs commented Dec 14, 2020

Copy link
Copy Markdown
Contributor

Add ability to use custom error message when wrong file type is used for file-input.js

Description

Previously there was a hardcoded value for the error message that was displayed inside the file-input component when the wrong file type was used that read: This is not a valid file type. For the project I am on, designers requested that the message be modified a little bit so this PR adds the ability to use a custom error message with the data-errormessage attribute on the input with class usa-file-input.

Additional information

Include any of the following (as necessary):

Here is a screenshot of the error with the updated text:
Screen Shot 2020-12-14 at 11 10 55 AM

I am not sure what documentation change (if any) need to be made but I am happy to make them if someone can point me in the right direction!

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

…m data attribute called 'errormessage' for a custom file type error message or to use the default value if one is not present
@thisisdano

Copy link
Copy Markdown
Contributor

Thanks for the PR. We'll give it a review and get back to you asap, but this looks useful!
cc @jaredcunha

@jaredcunha

Copy link
Copy Markdown
Contributor

This looks pretty intriguing. @thisisdano This is pretty close to what I had in mind for more broadly supporting localization in some of the other interactive components.

@hilvitzs

Copy link
Copy Markdown
Contributor Author

I'm so glad you think this might be beneficial @thisisdano. I was wondering if there was any timeline for getting this approved?

@jorgegonzalez

Copy link
Copy Markdown

Any updates on this?

@thisisdano

Copy link
Copy Markdown
Contributor

We were just talking about this today. I'd like to get this moving forward again. You should see some movement soon!

@thisisdano thisisdano added this to the USWDS 2.11.0 milestone Feb 25, 2021
@thisisdano thisisdano removed this from the USWDS 2.11.0 milestone Feb 26, 2021
@thisisdano thisisdano self-assigned this Mar 1, 2021
Comment thread src/js/components/file-input.js Outdated
mejiaj and others added 2 commits August 10, 2021 08:21
Use `textContent` instead of `innerHTML`.

Co-authored-by: Andrew Duthie <andrew@andrewduthie.com>
@thisisdano thisisdano merged commit 019eda3 into uswds:develop Sep 20, 2021
@thisisdano

Copy link
Copy Markdown
Contributor

Approved and merging. We'll be drafting a docs PR as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants