Skip to content

Commit ef74ed1

Browse files
author
Devang Bhavsar
committed
Include check for separator while filtering path of terms when anchorId is used with TaxonomyPicker control.
1 parent 8c178f0 commit ef74ed1

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/controls/taxonomyPicker/TermParent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export default class TermParent extends React.Component<ITermParentProps, ITermP
3737
{
3838
const anchorTerm = this._terms.filter(t => t.Id.toLowerCase() === this.props.anchorId.toLowerCase()).shift();
3939
if (anchorTerm) {
40-
const anchorDepth = anchorTerm.PathDepth;
40+
const anchorTermPath = anchorTerm.PathOfTerm + /* Append (;) separator, as a suffix to anchor term path. */ ';';
4141
this._anchorName = anchorTerm.Name;
42-
var anchorTerms : ITerm[] = this._terms.filter(t => t.PathOfTerm.substring(0, anchorTerm.PathOfTerm.length) === anchorTerm.PathOfTerm && t.Id !== anchorTerm.Id);
42+
let anchorTerms : ITerm[] = this._terms.filter(t => t.PathOfTerm.substring(0, anchorTermPath.length) === anchorTermPath && t.Id !== anchorTerm.Id);
4343

4444
anchorTerms = anchorTerms.map(term => {
4545
term.PathDepth = term.PathDepth - anchorTerm.PathDepth;

src/services/SPTermStorePickerService.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ export default class SPTermStorePickerService {
287287
return null;
288288
}
289289

290-
291290
private searchTermsBySearchText(terms, searchText) {
292291
if (terms) {
293292
return terms.filter((t) => { return t.name.toLowerCase().indexOf(searchText.toLowerCase()) > -1; });
@@ -296,7 +295,6 @@ export default class SPTermStorePickerService {
296295
return [];
297296
}
298297

299-
300298
public async searchTermsByTermId(searchText: string, termId: string): Promise<IPickerTerm[]> {
301299
if (Environment.type === EnvironmentType.Local) {
302300
// If the running environment is local, load the data from the mock
@@ -352,7 +350,8 @@ export default class SPTermStorePickerService {
352350
if (anchorId) {
353351
const anchorTerm = terms.filter(t => t.Id.toLowerCase() === anchorId.toLowerCase()).shift();
354352
if (anchorTerm) {
355-
const anchorTerms: ITerm[] = terms.filter(t => t.PathOfTerm.substring(0, anchorTerm.PathOfTerm.length) === anchorTerm.PathOfTerm && t.Id !== anchorTerm.Id);
353+
const anchorTermPath = anchorTerm.PathOfTerm + /* Append (;) separator, as a suffix to anchor term path. */ ';';
354+
const anchorTerms : ITerm[] = terms.filter(t => t.PathOfTerm.substring(0, anchorTermPath.length) === anchorTermPath && t.Id !== anchorTerm.Id);
356355

357356
anchorTerms.forEach(term => {
358357
returnTerms.push(this.convertTermToPickerTerm(term));

0 commit comments

Comments
 (0)