@@ -148,8 +148,8 @@ class TableEditColumn extends Component {
148
148
}
149
149
150
150
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 ( ) ;
153
153
}
154
154
}
155
155
@@ -159,6 +159,29 @@ class TableEditColumn extends Component {
159
159
}
160
160
}
161
161
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
+
162
185
render ( ) {
163
186
const {
164
187
editable,
@@ -170,15 +193,22 @@ class TableEditColumn extends Component {
170
193
} = this . props ;
171
194
const { shakeEditor } = this . state ;
172
195
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 )
176
200
} ;
177
201
let style = { position : 'relative' } ;
178
202
let { fieldValue } = this . props ;
179
203
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
+ }
182
212
183
213
const editorClass = classSet ( { 'animated' : shakeEditor , 'shake' : shakeEditor } ) ;
184
214
fieldValue = fieldValue === 0 ? '0' : fieldValue ;
0 commit comments