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

Clear text on value clear #37

Closed
tracerx opened this issue Nov 14, 2018 · 10 comments
Closed

Clear text on value clear #37

tracerx opened this issue Nov 14, 2018 · 10 comments
Labels
feature help wanted Extra attention is needed

Comments

@tracerx
Copy link

tracerx commented Nov 14, 2018

If the input is cleared using something like:
document.getElementById('fileInput').value = '';
The filename stays in place even though the underlying input has been cleared.

@Johann-S Johann-S added help wanted Extra attention is needed feature labels Nov 14, 2018
@Johann-S
Copy link
Owner

Maybe I should add a refresh method to handle that 🤔

Thanks for the feedback @tracerx 👍

@CometS1
Copy link

CometS1 commented Nov 15, 2018

I'll try to work on this, just tell me where I should create the refresh method

@Johann-S
Copy link
Owner

You can add in the bsCustomFileInput object here:
https://github.com/Johann-S/bs-custom-file-input/blob/master/src/index.js#L11

Thanks @CometS1 👍

@Johann-S
Copy link
Owner

Not sure if my PR here fix your issue: #39 🤔

@CometS1
Copy link

CometS1 commented Nov 16, 2018

I'm not sure either, @tracerx could you go into more detail about your issue, and check to see if the recent PR fixes it?

@Johann-S
Copy link
Owner

You can test that here: https://bs-custom-file-input.netlify.com/ 👍

@tracerx
Copy link
Author

tracerx commented Nov 19, 2018

That PR wouldn't fix this issue because changing the value in the JS won't fire the change event. As you suggested, a refresh method for the control would be needed. form.reset works but not if you just want to change the value of that control without resetting the rest of the form.

@Johann-S
Copy link
Owner

Johann-S commented Nov 19, 2018

Maybe before the PR of @CometS1, @tracerx you can try something like that:

var fileInput = document.getElementById('fileInput')
fileInput.value = ''
fileInput.dispatchEvent(new Event('change'))

EDIT:

BTW it works pretty well see: https://codepen.io/Johann-S/pen/LXOYbR

@tracerx
Copy link
Author

tracerx commented Nov 19, 2018

Yep. That does the trick. Thank you for your help and sorry for not thinking that through before opening an issue on it!

@tracerx tracerx closed this as completed Nov 19, 2018
@Johann-S
Copy link
Owner

No worries thanks you for using my plugin 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants