@@ -148,8 +148,8 @@ class TableEditColumn extends Component {
148148 }
149149
150150 focusInEditor ( ) {
151- if ( Util . isFunction ( this . refs . inputRef . focus ) ) {
152- this . refs . inputRef . focus ( ) ;
151+ if ( this . inputRef && Util . isFunction ( this . inputRef . focus ) ) {
152+ this . inputRef . focus ( ) ;
153153 }
154154 }
155155
@@ -159,6 +159,29 @@ class TableEditColumn extends Component {
159159 }
160160 }
161161
162+ getInputRef = userRef => ref => {
163+ this . inputRef = ref ;
164+ if ( Util . isFunction ( userRef ) ) {
165+ userRef ( ref ) ;
166+ } else if ( typeof userRef === 'string' ) {
167+ throw new Error ( 'Ref must be a function' ) ;
168+ }
169+ }
170+
171+ getHandleKeyPress = customHandler => e => {
172+ this . handleKeyPress ( e ) ;
173+ if ( Util . isFunction ( customHandler ) ) {
174+ customHandler ( e ) ;
175+ }
176+ }
177+
178+ getHandleBlur = customHandler => e => {
179+ this . handleBlur ( e ) ;
180+ if ( Util . isFunction ( customHandler ) ) {
181+ customHandler ( e ) ;
182+ }
183+ }
184+
162185 render ( ) {
163186 const {
164187 editable,
@@ -170,15 +193,22 @@ class TableEditColumn extends Component {
170193 } = this . props ;
171194 const { shakeEditor } = this . state ;
172195 const attr = {
173- ref : 'inputRef' ,
174- onKeyDown : this . handleKeyPress ,
175- onBlur : this . handleBlur
196+ ...editable . attrs ,
197+ ref : this . getInputRef ( editable . attrs && editable . attrs . ref ) ,
198+ onKeyDown : this . getHandleKeyPress ( editable . attrs && editable . attrs . onKeyDown ) ,
199+ onBlur : this . getHandleBlur ( editable . attrs && editable . attrs . onBlur )
176200 } ;
177201 let style = { position : 'relative' } ;
178202 let { fieldValue } = this . props ;
179203 let { className } = this . state ;
180- // put placeholder if exist
181- editable . placeholder && ( attr . placeholder = editable . placeholder ) ;
204+
205+ if ( editable . placeholder ) {
206+ attr . placeholder = editable . placeholder ;
207+ /* eslint-disable no-console */
208+ console . warn (
209+ 'Setting editable.placeholder is deprecated. Use editable.attrs to set input attributes' ) ;
210+ /* eslint-enable no-console */
211+ }
182212
183213 const editorClass = classSet ( { 'animated' : shakeEditor , 'shake' : shakeEditor } ) ;
184214 fieldValue = fieldValue === 0 ? '0' : fieldValue ;
0 commit comments