Skip to content

Commit

Permalink
Set new data on elements after fetch. (#80430)
Browse files Browse the repository at this point in the history
When `add`ing an element with an already existing ID, it will use the already existing data instead of setting new data. This made it so when you change the time picker the element health statuses would not update.

When we get new elements, replace the existing data for existing elements.

Fixes #80335.
  • Loading branch information
smith authored Oct 14, 2020
1 parent 396135a commit 5161f10
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ function CytoscapeComponent({
cy.elements().forEach((element) => {
if (!elementIds.includes(element.data('id'))) {
cy.remove(element);
} else {
// Doing an "add" with an element with the same id will keep the original
// element. Set the data with the new element data.
const newElement = elements.find((el) => el.data.id === element.id());
element.data(newElement?.data ?? element.data());
}
});
cy.trigger('custom:data', [fit]);
Expand Down

0 comments on commit 5161f10

Please sign in to comment.