Skip to content
Closed
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
1 change: 1 addition & 0 deletions draftlogs/8229_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix `_template` property leaking into user `layout` rangeslider axis options [[#8229](https://github.com/plotly/plotly.js/pull/8229)], with thanks to @abdulhamid999 for the contribution!
4 changes: 3 additions & 1 deletion src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,10 @@ function doAutoRange(gd, ax, presetRange) {
if(axeRangeOpts.rangemode === 'auto') {
axeRangeOpts.range = getAutoRange(gd, ax);
}
const inputRangeOpts = Lib.extendFlat({}, axeRangeOpts);
delete inputRangeOpts._template;
anchorAx._input.rangeslider[ax._name] = inputRangeOpts;
}
anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts);
}
}

Expand Down
39 changes: 39 additions & 0 deletions test/jasmine/tests/range_slider_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,45 @@ describe('rangesliders in general', function() {
})
.then(done, done.fail);
});

it('should not copy _template into layout rangeslider axis options', (done) => {
Plotly.newPlot(gd, [{
y: [1, 2, 3]
}], {
xaxis: {rangeslider: {visible: true}}
})
.then(() => {
expect('_template' in gd.layout.xaxis.rangeslider.yaxis).toBe(false);
expect(gd._fullLayout.xaxis.rangeslider.yaxis._template).toBe(null);

return Plotly.newPlot(gd, [{
y: [1, 2, 3]
}], {
xaxis: {rangeslider: {visible: true}},
template: {
layout: {
xaxis: {
rangeslider: {
yaxis: {rangemode: 'auto'}
}
}
}
}
});
})
.then(() => {
expect('_template' in gd.layout.xaxis.rangeslider.yaxis).toBe(false);
expect(gd.layout.xaxis.rangeslider.yaxis.rangemode).toEqual('auto');
expect(gd._fullLayout.xaxis.rangeslider.yaxis._template).toEqual({rangemode: 'auto'});

return Plotly.relayout(gd, 'xaxis.rangeslider.yaxis.rangemode', 'match');
})
.then(() => {
expect('_template' in gd.layout.xaxis.rangeslider.yaxis).toBe(false);
expect(gd.layout.xaxis.rangeslider.yaxis.rangemode).toEqual('match');
})
.then(done, done.fail);
});
});

function slide(fromX, fromY, toX, toY) {
Expand Down