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

Failure to call .focus() on custom input after selecting a date #636

Closed
avindra opened this issue Nov 23, 2016 · 11 comments
Closed

Failure to call .focus() on custom input after selecting a date #636

avindra opened this issue Nov 23, 2016 · 11 comments

Comments

@avindra
Copy link

avindra commented Nov 23, 2016

With a customInput set, where customInput has the <input> element deeply nested, react-datepicker will throw:

Uncaught TypeError: this.refs.input.focus is not a function(…)

after a date is selected.

A simple way to fix this behavior is to skip the .focus() step if customInput was passed.

Not sure what a clean solution would be to better support customInput.

@jochenberger
Copy link
Contributor

Can't use SFCs as custom inputs either because they cannot have refs.

@jochenberger
Copy link
Contributor

I ended up implementing a focus function in my custom component that focuses the input: http://codepen.io/jochenberger/pen/qqKrPd
That's pretty advanced stuff though, I with it was easier. This should probably go into the documentation.
cc @martijnrusschen

@dvdgarcia
Copy link

Same error here. I think we should be able to overwrite the onFocus like with onBlur or onChange.
I noticed that if I call the e.preventDefault in my own onBlur, i have not this error, but I lose the dateValidation.
So I think that if we use a customInput, we should have the focus event inside our component and we decide if we focus or not, for example in my case I have to change the focus to other element once I selected a date.

@seafarring13
Copy link

We are looking for this update as well. We had to use a custom input for layout/styling requirements and also see this error being thrown.

@igrek8
Copy link

igrek8 commented Jul 13, 2017

No updates?

@stamkov-sc
Copy link

You can fix error if overwrite onBlur event in custom input like <input type="text" onBlur={()=>{}}/>

@gigaga
Copy link

gigaga commented Aug 29, 2017

@stamkov-sc Does not work for me... :(
@jochenberger OK for me :)

@aij aij added the docs label Aug 29, 2017
@aij
Copy link
Contributor

aij commented Aug 29, 2017

@seafarring13 Does your custom input have a focus() method?

@ernani
Copy link

ernani commented Nov 11, 2017

This is not working for me, I have a functional component, won't work with this

@janhartmann
Copy link

Verified custom text input does throw this error

@stale
Copy link

stale bot commented Aug 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 30, 2019
@stale stale bot closed this as completed Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants