Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/jasmine/tests/shapes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down