diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 9bd8007dfc2..4fe0a28da59 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1979,9 +1979,10 @@ function _relayout(gd, aobj) { var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; - if(propStr === '') { + if(i !== '' && propStr === '') { // special handling of undoit if we're adding or removing an element - // ie 'annotations[2]' which can be {...} (add) or null (remove) + // ie 'annotations[2]' which can be {...} (add) or null, + // does not work when replacing the entire array if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { @@ -1990,7 +1991,6 @@ function _relayout(gd, aobj) { Lib.warn('unrecognized full object value', aobj); } } - editTypes.update(flags, updateValObject); // prepare the edits object we'll send to applyContainerArrayChanges diff --git a/test/jasmine/tests/shapes_test.js b/test/jasmine/tests/shapes_test.js index bc1198445a6..b096b925570 100644 --- a/test/jasmine/tests/shapes_test.js +++ b/test/jasmine/tests/shapes_test.js @@ -367,6 +367,8 @@ describe('Test shapes:', function() { }); it('can replace the shapes array', function(done) { + spyOn(Lib, 'warn'); + Plotly.relayout(gd, { shapes: [ getRandomShape(), getRandomShape() @@ -375,6 +377,7 @@ describe('Test shapes:', function() { expect(countShapePathsInLowerLayer()).toEqual(0); expect(countShapePathsInSubplots()).toEqual(0); expect(gd.layout.shapes.length).toBe(2); + expect(Lib.warn).not.toHaveBeenCalled(); }) .catch(failTest) .then(done);