File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ class InputHints extends Component {
8888 } )
8989 }
9090
91+ _getTextInputNode ( ) {
92+ return this . refTextInput
93+ }
94+
9195 tick ( ) {
9296 const { placeholders} = this . props
9397 const {
@@ -138,10 +142,23 @@ class InputHints extends Component {
138142 const placeholder = currentPlaceholder . slice ( 0 , currentCharPos )
139143
140144 return (
141- < input placeholder = { placeholder } { ...inputProps } />
145+ < input ref = { ( e ) => this . refTextInput = e } placeholder = { placeholder } { ...inputProps } />
142146 )
143147 }
144148
145149}
146150
147- module . exports = InputHints
151+ function inputWrapper ( WrappedComponent ) {
152+ class Input extends Component {
153+ focus ( ) { this . c . _getTextInputNode ( ) . focus ( ) }
154+ blur ( ) { this . c . _getTextInputNode ( ) . blur ( ) }
155+
156+ render ( ) {
157+ return < WrappedComponent { ...this . props } ref = { ( c ) => this . c = c } />
158+ }
159+ }
160+ Input . displayName = WrappedComponent . displayName || 'Component'
161+ return input
162+ }
163+
164+ module . exports = inputWrapper ( InputHints )
You can’t perform that action at this time.
0 commit comments