Skip to content

Commit

Permalink
CSCFC4EMSCR-602 When filtering from mappings, results get duplicated.…
Browse files Browse the repository at this point in the history
… Added check that allows adding searched item only once to searced items array.
  • Loading branch information
masillan committed Nov 11, 2024
1 parent 20830aa commit dccae7b
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions mscr-ui/src/modules/crosswalk-editor/mappings-accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,19 +421,27 @@ function filterMappings(nodeMappingsInput: NodeMapping[], value: string, showAtt
let results: NodeMapping[] = [];
const searchString = value.toLowerCase();
nodeMappingsInput.forEach(item => {
if (item?.notes && item.notes.toLowerCase().includes(searchString)) {
let itemFound = false
if (item?.notes && item.notes.toLowerCase().includes(searchString) && !itemFound) {
results.push(item);
itemFound = true;
}
if (!itemFound) {
item.source.forEach(src => {
if (src.label.toLowerCase().includes(searchString) && !itemFound) {
results.push(item);
itemFound = true;
}
});
}
if (!itemFound) {
item.target.forEach(src => {
if (src.label.toLowerCase().includes(searchString) && !itemFound) {
results.push(item);
itemFound = true;
}
});
}
item.source.forEach(src => {
if (src.label.toLowerCase().includes(searchString)) {
results.push(item);
}
});
item.target.forEach(src => {
if (src.label.toLowerCase().includes(searchString)) {
results.push(item);
}
});
}
);
return results;
Expand Down

0 comments on commit dccae7b

Please sign in to comment.