From 50172d494c9c8298740203ece123cca5b60f51c2 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Fri, 8 Nov 2019 14:30:02 -0500 Subject: [PATCH] Skip processing of child paths in color swap --- src/helper/style-path.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/helper/style-path.js b/src/helper/style-path.js index 2f5ecb84..508c2f0c 100644 --- a/src/helper/style-path.js +++ b/src/helper/style-path.js @@ -6,6 +6,7 @@ import {getItems} from './selection'; import GradientTypes from '../lib/gradient-types'; import parseColor from 'parse-color'; import {DEFAULT_COLOR} from '../reducers/fill-color'; +import {isCompoundPathChild} from '../helper/compound-path'; const MIXED = 'scratch-paint/style-path/mixed'; @@ -159,10 +160,11 @@ const applyFillColorToSelection = function (colorString, colorIndex, isSolidGrad const swapColorsInSelection = function (bitmapMode, textEditTargetId) { const items = _getColorStateListeners(textEditTargetId); let changed = false; - for (let item of items) { - if (item.parent instanceof paper.CompoundPath) { - item = item.parent; - } + for (const item of items) { + // If an item is a child path, do not swap colors. + // At some point, we'll iterate over its parent path, and we don't want to swap colors twice-- + // that would leave us right where we started. + if (isCompoundPathChild(item)) continue; if (bitmapMode) { // @todo