-
Notifications
You must be signed in to change notification settings - Fork 1.1k
USWDS - File Input: Move imageId for larger scope. Resolves #5088 #5114
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
Conversation
|
@mejiaj @amyleadem Bumping for review if either of you have time today or next week! |
|
Hi @mahoneycm, I did some preliminary testing and found that the loader now either freezes for a bit before showing the preview image OR doesn’t appear at all. Are you seeing the same thing?
|
|
@amyleadem @mahoneycm I wasn't able to reproduce with a 651MB ZIP (using slow 3G network throttling). Attached video below of current component on file-input-develop-2023-02-08.at.10.19.45.webm |
@amyleadem Yes I'm seeing the same thing, but only when the icon swap happens successfully. If the attachment takes too long I still see the infinite spinning loader. Here's a clip where I'm attempting to attach the same file on the current federalist build and on this PR branch. Screen.Recording.2023-02-08.at.10.43.52.AM.movThere are times where the network connection is fast enough and the current build does successfully attach the file which results in the spinner pause and file image replacement though. I think if the file upload takes a few second or on the turnover of a new minute it causes the ID's to mismatch and doesn't replace the spinner correctly. We can take a look at what is causing that pause as well either in this ticket or in a new issue |
|
@mejiaj When I first tried to confirm this bug I had trouble recreating it as well. The network throttling didn't seem to affect it for some reason but I kept trying different files and I began seeing the bug. I believe it has to do with the time you start the attachment vs when the attachment ends. It does seem to be rare though so potentially an edge case. |
|
@amyleadem with the examples above can you interact at all with the browser? Like right click or select text. I was able to reproduce the loader icon freezing, but that's because the entire browser was frozen for a second. |
|
@mejiaj I am not able to interact with the browser when the loader icon is frozen. The browser itself does seem to be frozen during that time. |
|
@mejiaj @amyleadem since the freeze seems to be related to the browser freezing, should we go ahead and push this along? |
mejiaj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ID is unique and doesn't change once the file is done loading.
|
I'll draw up a changelog PR for this change. |
Summary
This change declares
imageIdoutside of theonloadstart()andonloadend()functions to ensure the same target is selected and replaced by the preview image if the attachment takes too long to attach.Related issue
Closes #5088
Preview link
Preview link: File Input →
Problem statement
createUniqueID()uses the current time to create theImageIdvariable. When a large file takes time to upload, it can causeonloadstartandonloadendto generate different image IDs.Solution
By declaring the variable before the functions, we can use
createUniqueID()only once and pass the variable through both functions.Testing and review