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

How set focus on InputMask element?

Open solo-framework opened this issue 5 years ago • 3 comments

Could you show me an example how to set focus on masked input text? I treid autoFocus={true} but it doesn't work

solo-framework avatar Feb 20 '20 08:02 solo-framework

For me it worked simply by adding autoFocus directly to the <inputMask />, but you can also test it this way: this.inputRef.getInputDOMNode().focus();.

Credits by @duhwcarvalho

jrmarqueshd avatar Mar 16 '20 17:03 jrmarqueshd

This is documented: https://github.com/sanniassin/react-input-mask/tree/v2#inputref--function

compwright avatar Jan 04 '21 20:01 compwright

I got solution by using javascript html passing id and try { window.document.getElementById("expiryDtId").focus(); } catch (error) { console.error(error); } works for me

cristoferrao avatar Jan 12 '23 04:01 cristoferrao