Auto focus of text fields and javascript

Been trying to get this for a few hours now, but i was hoping someone here might be able to provide a real example of how to accomplish this. On my app I wanted to make the first input field autofocus in a form when the page loads, and after submit I wanted to focus() and select() that same input so it was easy to re-input.

1 Like

Hey @chrisgoffinet, sorry for the delay! We don’t support focus methods quite yet, but you’re actually the second person to request them this week. Will forward to the team!

2 Likes

@justin +1! Make that 3 requests this week!

1 Like

@chrisgoffinet + @IsaiahJTurner

Text inputs now support a textinput.focus() JS method that can be used inside of Run JS Code queries to focus the input :grin:

2 Likes

@alex-w
Trying textinput.focus(). Works great.
However when I embed the same textinput inside a wizard component, textinput.focus() doesn’t seem to work.

Hey @SumitJ and welcome to the forums! It seems to be working for me - any chance you could share a video here?

I have noticed that this also doesn’t work with number inputs (currency format). It just shows '0.00' and I can focus to the input but then it still requires the user to deleted the "0.00" before entering in their number.

Is there a workaround I can do to get this to work? Thanks!

Hey @macphreak! That's definitely a valid point. I went ahead and filed a request to remove the 0.00 when there's no default value set so users don't have to delete it every time.