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 {
4646 super ( props ) ;
4747 this . el = null ;
4848 this . forceUpdateValue = false ;
49+ this . initialRender = true ;
4950 }
5051
5152 componentDidMount ( ) {
@@ -54,6 +55,7 @@ export default class Select2 extends Component {
5455 }
5556
5657 componentWillReceiveProps ( nextProps ) {
58+ this . initialRender = false ;
5759 this . updSelect2 ( nextProps ) ;
5860 }
5961
@@ -104,7 +106,17 @@ export default class Select2 extends Component {
104106 const currentValue = multiple ? this . el . val ( ) || [ ] : this . el . val ( ) ;
105107
106108 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+
107115 this . el . val ( newValue ) . trigger ( 'change' ) ;
116+
117+ if ( this . initialRender && onChange ) {
118+ this . el . on ( `change.${ namespace } ` , onChange ) ;
119+ }
108120 this . forceUpdateValue = false ;
109121 }
110122 }
You can’t perform that action at this time.
0 commit comments