@@ -122,10 +122,6 @@ function createControlClass(customControlPropsMap = {}, s = defaultStrategy) {
122
122
...customControlPropsMap ,
123
123
} ;
124
124
125
- function isReadOnlyValue ( controlProps ) {
126
- return ~ [ 'radio' , 'checkbox' ] . indexOf ( controlProps . type ) ;
127
- }
128
-
129
125
const emptyControlProps = { } ;
130
126
131
127
class Control extends Component {
@@ -144,7 +140,6 @@ function createControlClass(customControlPropsMap = {}, s = defaultStrategy) {
144
140
this . handleLoad = this . handleLoad . bind ( this ) ;
145
141
this . getMappedProps = this . getMappedProps . bind ( this ) ;
146
142
this . attachNode = this . attachNode . bind ( this ) ;
147
- this . readOnlyValue = isReadOnlyValue ( props . controlProps ) ;
148
143
149
144
this . willValidate = false ;
150
145
@@ -226,7 +221,7 @@ function createControlClass(customControlPropsMap = {}, s = defaultStrategy) {
226
221
modelValue,
227
222
changeAction,
228
223
} = this . props ;
229
- const value = this . readOnlyValue
224
+ const value = this . isReadOnlyValue ( )
230
225
? getReadOnlyValue ( this . props )
231
226
: event ;
232
227
@@ -351,11 +346,17 @@ function createControlClass(customControlPropsMap = {}, s = defaultStrategy) {
351
346
}
352
347
353
348
setViewValue ( viewValue ) {
354
- if ( ! isReadOnlyValue ( this . props . controlProps ) ) {
349
+ if ( ! this . isReadOnlyValue ( ) ) {
355
350
this . setState ( { viewValue : this . parse ( viewValue ) } ) ;
356
351
}
357
352
}
358
353
354
+ isReadOnlyValue ( ) {
355
+ const { component, controlProps } = this . props ;
356
+
357
+ return component === 'input' && ~ [ 'radio' , 'checkbox' ] . indexOf ( controlProps . type ) ;
358
+ }
359
+
359
360
handleIntents ( ) {
360
361
const {
361
362
model,
@@ -375,12 +376,11 @@ function createControlClass(customControlPropsMap = {}, s = defaultStrategy) {
375
376
case actionTypes . FOCUS : {
376
377
if ( isNative ) return ;
377
378
378
- const readOnlyValue = isReadOnlyValue ( controlProps ) ;
379
379
const focused = fieldValue . focus ;
380
380
381
381
if ( ( focused && this . node . focus )
382
382
&& (
383
- ! readOnlyValue
383
+ ! this . isReadOnlyValue ( )
384
384
|| typeof intent . value === 'undefined'
385
385
|| intent . value === controlProps . value
386
386
) ) {
@@ -521,7 +521,7 @@ function createControlClass(customControlPropsMap = {}, s = defaultStrategy) {
521
521
: event ;
522
522
}
523
523
524
- if ( isReadOnlyValue ( controlProps ) ) {
524
+ if ( this . isReadOnlyValue ( ) ) {
525
525
return compose (
526
526
dispatchBatchActions ,
527
527
persistEventWithCallback ( controlEventHandler || identity )
0 commit comments