diff --git a/draftlogs/8161_fix.md b/draftlogs/8161_fix.md new file mode 100644 index 00000000000..40b61659622 --- /dev/null +++ b/draftlogs/8161_fix.md @@ -0,0 +1 @@ +- Do not leak internal `_template` property into input `layout` rangeslider opposing axis containers [[#8161](https://github.com/plotly/plotly.js/pull/8161)] diff --git a/src/plots/cartesian/autorange.js b/src/plots/cartesian/autorange.js index 9113cd855d4..ca337ee0bc0 100644 --- a/src/plots/cartesian/autorange.js +++ b/src/plots/cartesian/autorange.js @@ -402,7 +402,9 @@ function doAutoRange(gd, ax, presetRange) { axeRangeOpts.range = getAutoRange(gd, ax); } } - anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + var inOpts = Lib.extendFlat({}, axeRangeOpts); + delete inOpts._template; + anchorAx._input.rangeslider[ax._name] = inOpts; } } diff --git a/test/jasmine/tests/range_slider_test.js b/test/jasmine/tests/range_slider_test.js index fed44189d9a..02bdc34d7ce 100644 --- a/test/jasmine/tests/range_slider_test.js +++ b/test/jasmine/tests/range_slider_test.js @@ -946,6 +946,32 @@ describe('rangesliders in general', function() { .then(done, done.fail); }); + it('should not leak _template into input layout rangeslider opp-axis container', function(done) { + Plotly.newPlot(gd, [{ x: [1, 2, 3], y: [1, 2, 3] }], { xaxis: { rangeslider: {} }}) + .then(function() { + expect(gd.layout.xaxis.rangeslider.yaxis).toBeDefined(); + expect(gd.layout.xaxis.rangeslider.yaxis._template).toBeUndefined(); + expect(gd._fullLayout.xaxis.rangeslider.yaxis._template).toBeDefined(); + }) + .then(done, done.fail); + }); + + it('should not leak _template into input layout when a template is used', function(done) { + Plotly.newPlot(gd, [{ x: [1, 2, 3], y: [1, 2, 3] }], { + template: { + layout: { + xaxis: { rangeslider: { yaxis: { rangemode: 'auto' } } } + } + }, + xaxis: { rangeslider: {} } + }) + .then(function() { + expect(gd.layout.xaxis.rangeslider.yaxis).toBeDefined(); + expect(gd.layout.xaxis.rangeslider.yaxis._template).toBeUndefined(); + }) + .then(done, done.fail); + }); + it('should plot when only y data is provided', function(done) { Plotly.newPlot(gd, [{ y: [1, 2, 3] }], { xaxis: { rangeslider: {} }}) .then(function() {