uswds
uswds copied to clipboard
USWDS - Bug: File input disappears when file is removed
Describe the bug
Based on https://designsystem.digital.gov/components/file-input/
For our Drupal instance the format and text appear perfectly. But when a file is added and then removed the default format is lost.
Steps to reproduce the bug
- On a page with file input
- Add a file
- Remove the file
Expected Behavior
If all files are removed the default format would be used.
Related code
No response
Screenshots
No response
System setup
No response
Additional context
Believe the usa-file-input__instructions is not returning
Code of Conduct
- [X] I agree to follow this project's Code of Conduct.
- [X] I checked the current issues for duplicate bug reports.
Also did a local check and the input field loads correct but if you click on another tab it goes away

@smustgrave I haven't been able to reproduce on develop preview branch
@mejiaj if you're doing the storybook locally and load the file input page. Click to another another page and then come back to the file input. The styling is gone.
Hello @smustgrave, In the default view mode in Storybook, you will need to hit reload on the component page every time you open it in order to initialize the associated Javascript and trigger the appropriate styles.
This isn't an indication that the component is broken - instead it is just a limitation of that Storybook view at this time (We are looking into a solution). If you instead open that same component story in a new tab (accessed by clicking on the icon in the screenshot below), you should be able to add and remove files to the component without anything breaking. This should work for your local Storybook build as well.
Does this answer your question and resolve your issue? If not, please let me know and I will cycle back.
Thank you for that.! Will see how to extend that to Drupal next
Know this isn't uswds problem but is there a way to rerun that js when the field changes?
Drupal will render the markup on load but when a file is uploaded and removed it no longer appears.
Think this is because Drupal is injecting a widget into field and removing what was there.
Just curious