@@ -40,6 +40,7 @@ const Select = ({
4040 value,
4141 onChange,
4242 loadOptionsChangeCounter,
43+ noValueUpdates,
4344 ...props
4445} ) => {
4546 const [ state , dispatch ] = useReducer ( reducer , {
@@ -56,13 +57,15 @@ const Select = ({
5657
5758 return loadOptions ( ) . then ( ( data ) => {
5859 if ( isMounted ) {
59- if ( value && Array . isArray ( value ) ) {
60- const selectValue = value . filter ( ( value ) =>
61- typeof value === 'object' ? data . find ( ( option ) => value . value === option . value ) : data . find ( ( option ) => value === option . value )
62- ) ;
63- onChange ( selectValue . length === 0 ? undefined : selectValue ) ;
64- } else if ( value && ! data . find ( ( { value : internalValue } ) => internalValue === value ) ) {
65- onChange ( undefined ) ;
60+ if ( ! noValueUpdates ) {
61+ if ( value && Array . isArray ( value ) ) {
62+ const selectValue = value . filter ( ( value ) =>
63+ typeof value === 'object' ? data . find ( ( option ) => value . value === option . value ) : data . find ( ( option ) => value === option . value )
64+ ) ;
65+ onChange ( selectValue . length === 0 ? undefined : selectValue ) ;
66+ } else if ( value && ! data . find ( ( { value : internalValue } ) => internalValue === value ) ) {
67+ onChange ( undefined ) ;
68+ }
6669 }
6770
6871 dispatch ( { type : 'updateOptions' , payload : data } ) ;
@@ -88,7 +91,7 @@ const Select = ({
8891
8992 useEffect ( ( ) => {
9093 if ( state . isInitialLoaded ) {
91- if ( value && ! propsOptions . map ( ( { value } ) => value ) . includes ( value ) ) {
94+ if ( ! noValueUpdates && value && ! propsOptions . map ( ( { value } ) => value ) . includes ( value ) ) {
9295 onChange ( undefined ) ;
9396 }
9497
@@ -176,7 +179,8 @@ Select.propTypes = {
176179 selectVariant : PropTypes . string ,
177180 updatingMessage : PropTypes . node ,
178181 noOptionsMessage : PropTypes . node ,
179- isSearchable : PropTypes . bool
182+ isSearchable : PropTypes . bool ,
183+ noValueUpdates : PropTypes . bool
180184} ;
181185
182186Select . defaultProps = {
0 commit comments