react-file-input icon indicating copy to clipboard operation
react-file-input copied to clipboard

Difficult to understand how to trigger the file input click programatically

Open justin-hackin opened this issue 9 years ago • 1 comments

A common use case for a file input is to make it hidden and trigger a click on the input from another button. The way this is designed, it is difficult for me to understand how one could possibly do this. I tried giving the component a ref and then running "this.refs.fileImportInput.getDOMNode().click()" but I could not trigger it this way.

justin-hackin avatar Feb 11 '16 03:02 justin-hackin

Hey.

So this library sets out to handle the hiding and click-delegation that you've described in one opinionated way: using a text box as the "controlling" element. Further, it was developed without consideration for programmatic interaction - just user driven events.

It seems to me like you want to use a button instead of a text box - that is something this lib definitely does not support... If that is the case, I would suggest either making a PR to add this new capability, or use the source code here as a guide in helping you achieve what you want with React.

Thanks!

dbarbalato avatar Feb 24 '16 17:02 dbarbalato