uswds icon indicating copy to clipboard operation
uswds copied to clipboard

USWDS - Bug: File input disappears when file is removed

Open smustgrave opened this issue 2 years ago • 6 comments

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

  1. On a page with file input
  2. Add a file
  3. 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

smustgrave avatar Jun 28 '22 20:06 smustgrave

Also did a local check and the input field loads correct but if you click on another tab it goes away

Screen Shot 2022-06-28 at 6 49 49 PM

smustgrave avatar Jun 28 '22 22:06 smustgrave

@smustgrave I haven't been able to reproduce on develop preview branch

Screen Recording 2022-06-29 at 8.44.29 AM.webm

mejiaj avatar Jun 29 '22 13:06 mejiaj

@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.

smustgrave avatar Jun 29 '22 14:06 smustgrave

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.

image

Does this answer your question and resolve your issue? If not, please let me know and I will cycle back.

amyleadem avatar Jun 29 '22 18:06 amyleadem

Thank you for that.! Will see how to extend that to Drupal next

smustgrave avatar Jun 29 '22 18:06 smustgrave

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

smustgrave avatar Jun 29 '22 20:06 smustgrave