From 5110a0c4c667d37b29ffcb91bfd6c2a17f3b0d41 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 21 Dec 2021 14:13:35 +0100 Subject: [PATCH] Don't update main prop on change of composite --- src/style_manager/index.js | 3 ++- test/specs/style_manager/model/Properties.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/style_manager/index.js b/src/style_manager/index.js index 9225d34d8..41f4bc9ec 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -586,6 +586,7 @@ export default () => { const isStack = prop.getType() === 'stack'; const isComposite = prop.getType() === 'composite'; const opt = { ...opts, __up: true }; + const canUpdate = !isComposite; let newLayers = isStack ? prop.__getLayersFromStyle(style) : []; let newProps = isComposite ? prop.__getPropsFromStyle(style) : {}; let newValue = hasVal ? value : null; @@ -616,7 +617,7 @@ export default () => { } prop.__setParentTarget(parentTarget); - prop.__getFullValue() !== newValue && prop.upValue(newValue, opt); + canUpdate && prop.__getFullValue() !== newValue && prop.upValue(newValue, opt); isStack && prop.__setLayers(newLayers || []); if (isComposite) { const props = prop.getProperties(); diff --git a/test/specs/style_manager/model/Properties.js b/test/specs/style_manager/model/Properties.js index dc0e66933..625353b6c 100644 --- a/test/specs/style_manager/model/Properties.js +++ b/test/specs/style_manager/model/Properties.js @@ -395,6 +395,21 @@ describe('StyleManager properties logic', () => { }); }); + test('Update on the rule reflects to the property correctly', () => { + rule1.setStyle({ padding: '1px 2px 3px 4px' }); + obj.__upSel(); + compTypeProp.getProperty(propCTest).upValue('50%'); + [ + [propATest, '1px'], + [propBTest, '2px'], + [propCTest, '50%'], + [propDTest, '4px'], + ].forEach(item => { + const prop = compTypeProp.getProperty(item[0]); + expect(prop.getFullValue()).toBe(item[1]); + }); + }); + test('Update on properties reflects to the rule correctly', () => { compTypeProp.set('detached', false); rule1.setStyle({ padding: '1px 2px 3px 4px' });