@@ -111,7 +111,9 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
111
111
let isValidateOnLoad = validateOnLoad && initialValues && initialValues . length >= 1 ;
112
112
if ( isValidateOnLoad ) {
113
113
114
- let notFoundTerms : string [ ] = [ ] ;
114
+ const notFoundTerms : string [ ] = [ ] ;
115
+ const notFoundTermIds : string [ ] = [ ] ;
116
+
115
117
const termSet = await this . termsService . getAllTerms ( termsetNameOrID , hideDeprecatedTags , hideTagsNotAvailableForTagging ) ;
116
118
const allTerms = termSet . Terms ;
117
119
@@ -120,12 +122,14 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
120
122
121
123
if ( ! allTerms . filter ( t => t . Id === pickerTerm . key ) . length ) {
122
124
notFoundTerms . push ( pickerTerm . name ) ;
125
+ notFoundTermIds . push ( pickerTerm . key ) ;
123
126
}
124
127
}
125
128
126
129
if ( notFoundTerms . length ) {
127
130
this . setState ( {
128
- internalErrorMessage : strings . TaxonomyPickerTermsNotFound . replace ( '{0}' , notFoundTerms . join ( ', ' ) )
131
+ internalErrorMessage : strings . TaxonomyPickerTermsNotFound . replace ( '{0}' , notFoundTerms . join ( ', ' ) ) ,
132
+ invalidNodeIds : notFoundTermIds
129
133
} ) ;
130
134
}
131
135
}
@@ -312,6 +316,23 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
312
316
}
313
317
314
318
private validate = async ( value : IPickerTerms ) : Promise < void > => {
319
+
320
+ //
321
+ // checking if there are any invalid nodes left after initial validation
322
+ //
323
+ if ( this . state . invalidNodeIds ) {
324
+ const changedInvalidNodeIds = this . state . invalidNodeIds . filter ( id => {
325
+ return ! ! value . filter ( term => term . key === id ) . length ;
326
+ } ) ;
327
+
328
+ let internalErrorMessage = changedInvalidNodeIds . length ? this . state . internalErrorMessage : '' ;
329
+
330
+ this . setState ( {
331
+ invalidNodeIds : changedInvalidNodeIds ,
332
+ internalErrorMessage : internalErrorMessage
333
+ } ) ;
334
+ }
335
+
315
336
if ( this . props . errorMessage || ! this . props . onGetErrorMessage ) { // ignoring all onGetErrorMessage logic
316
337
this . validated ( value ) ;
317
338
return ;
0 commit comments