From afa319544a800fe5795fcde5114963166de1060e Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Mon, 13 Dec 2021 15:02:30 +0100 Subject: [PATCH] Update style properly on layers change --- src/style_manager/model/PropertyStack.js | 18 +++++++++++++++--- test/specs/style_manager/model/Properties.js | 8 +++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/style_manager/model/PropertyStack.js b/src/style_manager/model/PropertyStack.js index d995e9033..37ba9a937 100644 --- a/src/style_manager/model/PropertyStack.js +++ b/src/style_manager/model/PropertyStack.js @@ -55,6 +55,13 @@ export default Property.extend({ layer.upValues({ [name]: prop.__getFullValue() }); const value = this.__getFullValue(); this.upValue(value, opts); + this.__upTargetsStyleProps(opts); + }, + + __upLayers(m, c, o) { + const value = this.__getFullValue(); + this.upValue(value); + this.__upTargetsStyleProps(o || c); }, __upTargets(p, opts = {}) { @@ -66,9 +73,14 @@ export default Property.extend({ return PropertyBase.prototype.__upTargetsStyle.call(this, style, opts); }, - __upLayers(m, c, o) { - const value = this.__getFullValue(); - this.upValue(value); + __upTargetsStyleProps(opts = {}) { + if (!this.isDetached()) { + const style = this.getProperties().reduce((acc, prop) => { + acc[prop.getName()] = ''; + return acc; + }, {}); + this.__upTargetsStyle(style, opts); + } }, __upSelected({ noEvent } = {}, opts = {}) { diff --git a/test/specs/style_manager/model/Properties.js b/test/specs/style_manager/model/Properties.js index cd31d3580..4139ed915 100644 --- a/test/specs/style_manager/model/Properties.js +++ b/test/specs/style_manager/model/Properties.js @@ -184,6 +184,9 @@ describe('StyleManager properties logic', () => { expect(rule1.getStyle()).toEqual({ __p: false, [propTest]: 'valueA-1 valueB-1-mod valueC-1-ext, valueA-2 valueB-2 valueC-2-mod', + [propATest]: '', + [propBTest]: '', + [propCTest]: '', }); }); @@ -191,7 +194,10 @@ describe('StyleManager properties logic', () => { compTypeProp.removeLayerAt(1); expect(rule1.getStyle()).toEqual({ __p: false, - [propTest]: 'valueA-1 valueB-1 valueC-1', + [propTest]: 'valueA-1 valueB-1 valueC-1-ext', + [propATest]: '', + [propBTest]: '', + [propCTest]: '', }); }); });