Skip to content
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

Reset uploader component #739

Closed
tpcgold opened this issue Aug 5, 2024 · 3 comments · Fixed by #815
Closed

Reset uploader component #739

tpcgold opened this issue Aug 5, 2024 · 3 comments · Fixed by #815
Assignees
Labels
bug Something isn't working

Comments

@tpcgold
Copy link

tpcgold commented Aug 5, 2024

Describe the bug
Currently MESOP Uploader component cannot be reloaded / refreshed / reset
https://google.github.io/mesop/components/uploader/

To Reproduce
Upload a file with the uploader component and you fill get the "file name" beside the upload button.
But if one is implementing a "clear" button (e.g. in a chat) it is not possible to remove the "file name" text after the uploader button.

Expected behavior
Add a clear / refresh feature for the component

Screenshots
Before:
image
After pressing clear (this removes UploadedFile from state) but the uploader component (file name) cannot be "reset" and still shows the demo-image1.png
image

@tpcgold tpcgold added the bug Something isn't working label Aug 5, 2024
@richard-to richard-to self-assigned this Aug 5, 2024
@richard-to
Copy link
Collaborator

Thanks for bringing this up. I've noticed this too. I'll take a look this week. Seems like it should be fixable, but if not I think this could work: https://google.github.io/mesop/components/?h=reset#resetting-a-component as a temporary workaround.

@richard-to
Copy link
Collaborator

richard-to commented Aug 8, 2024

Here are a few options (no particular order) API-wise:

  1. Add a clear parameter. Then when cleared, send an on_clear event back to the server so that the clear parameter can be disabled. Needing to include on_clear hook to reset seems a bit tedious though

  2. Add a filename parameter. If set to empty string, then the value will be cleared. If set, then the given filename will be displayed.

  3. Just use the reset component use the key update workaround above.

I think I'm going to go with option 2. This way, a user can upload a file and no filename will show at all (if that's what they want). This works for now since the upload is immediate. No need to select a file and press an upload button. The main drawback with number 2 is if a user sets a filename even though nothing has been uploaded. But I think that is OK.

@richard-to
Copy link
Collaborator

Sorry for the delay on this. Thought I could get to it before I went OOO for a week. Unfortunately did not get to it.

My solution for this ended up being to remove the labels altogether. I realized they were a bit redundant and could be added manually in Mesop anyway which would give more flexibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants