Skip to content

Commit

Permalink
sync related region color when tag color changed (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
yongbing-chen authored Sep 29, 2020
1 parent 3e503e7 commit 3044cc5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/react/components/pages/editorPage/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1993,11 +1993,17 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
}

const prevTypes = {};
prevTags.forEach((tag) => prevTypes[tag.name] = tag.type);

const prevColors = {};
prevTags.forEach((tag) => {
prevTypes[tag.name] = tag.type;
prevColors[tag.name] = tag.color;
});
const types = {};
tags.forEach((tag) => types[tag.name] = tag.type);

const colors = {};
tags.forEach((tag) => {
types[tag.name] = tag.type;
colors[tag.name] = tag.color;
});
for (const name of names) {
const prevType = prevTypes[name];
const type = types[name];
Expand All @@ -2006,6 +2012,12 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
// some tag change between checkbox and text
return true;
}
const prevColor = prevColors[name];
const color = colors[name];
if (prevColor !== color) {
// some tag color changed
return true;
}
}

return false;
Expand Down

0 comments on commit 3044cc5

Please sign in to comment.