File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ export default class Select2 extends Component {
46
46
super ( props ) ;
47
47
this . el = null ;
48
48
this . forceUpdateValue = false ;
49
+ this . initialRender = true ;
49
50
}
50
51
51
52
componentDidMount ( ) {
@@ -54,6 +55,7 @@ export default class Select2 extends Component {
54
55
}
55
56
56
57
componentWillReceiveProps ( nextProps ) {
58
+ this . initialRender = false ;
57
59
this . updSelect2 ( nextProps ) ;
58
60
}
59
61
@@ -104,7 +106,17 @@ export default class Select2 extends Component {
104
106
const currentValue = multiple ? this . el . val ( ) || [ ] : this . el . val ( ) ;
105
107
106
108
if ( ! shallowEqualFuzzy ( currentValue , newValue ) || this . forceUpdateValue ) {
109
+ const onChange = this . props . onChange ;
110
+
111
+ if ( this . initialRender && onChange ) {
112
+ this . el . off ( `change.${ namespace } ` ) ;
113
+ }
114
+
107
115
this . el . val ( newValue ) . trigger ( 'change' ) ;
116
+
117
+ if ( this . initialRender && onChange ) {
118
+ this . el . on ( `change.${ namespace } ` , onChange ) ;
119
+ }
108
120
this . forceUpdateValue = false ;
109
121
}
110
122
}
You can’t perform that action at this time.
0 commit comments