From 3044cc51a9166877bb4f01f28753171b82c04ccd Mon Sep 17 00:00:00 2001 From: Alex Chen <68627897+yongbing-chen@users.noreply.github.com> Date: Tue, 29 Sep 2020 12:14:16 +0800 Subject: [PATCH] sync related region color when tag color changed (#598) --- .../components/pages/editorPage/canvas.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/react/components/pages/editorPage/canvas.tsx b/src/react/components/pages/editorPage/canvas.tsx index 8d4a3e8d1..045bfd697 100644 --- a/src/react/components/pages/editorPage/canvas.tsx +++ b/src/react/components/pages/editorPage/canvas.tsx @@ -1993,11 +1993,17 @@ export default class Canvas extends React.Component } 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]; @@ -2006,6 +2012,12 @@ export default class Canvas extends React.Component // 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;