Skip to content

Prevent internal _template leak into layout rangeslider opp-axis (#6310) - #8161

Open
davrens101 wants to merge 2 commits into
plotly:mainfrom
davrens101:fix/rangeslider-template-leak-6310
Open

davrens101 wants to merge 2 commits into
plotly:mainfrom
davrens101:fix/rangeslider-template-leak-6310

Conversation

@davrens101

Copy link
Copy Markdown

Prevent internal _template leak into layout rangeslider opp-axis

Fixes #6310.

When an axis with a rangeslider autoranges in doAutoRange (src/plots/cartesian/autorange.js), axeRangeOpts for each opposing axis is copied back into anchorAx._input.rangeslider[ax._name]. Because axeRangeOpts is instantiated via Template.newContainer in rangeslider/defaults.js, it contains an internal _template property (either null or a template object). Copying the whole object into anchorAx._input pollutes the user-facing layout object with _template: null under rangeslider[yaxis].

This non-schema property causes serialization and validation failures in downstream consumers such as Dash Python (ValueError: Invalid property specified for object of type plotly.graph_objs.layout.xaxis.rangeslider.YAxis: '_template').

Solution

Delete _template from the copied options object before assigning back to anchorAx._input.rangeslider[ax._name]. The internal _template property remains intact on _fullLayout as expected.

Regression coverage

Added two unit tests in test/jasmine/tests/range_slider_test.js:

  1. should not leak _template into input layout rangeslider opp-axis container
  2. should not leak _template into input layout when a template is used

Prior to the fix:
expect(gd.layout.xaxis.rangeslider.yaxis._template).toBeUndefined() failed with Error: Expected null to be undefined.

With the fix:
Both tests pass cleanly. template_test.js passes 14 of 14 tests. Biome linter passes without warnings.

Review and disclosure

AI assisted the patch, regression tests, and PR description. Verified against Jasmine test suite and Biome linter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rangeslider template bug (non-attribute inserted into layout instead of fullLayout)

2 participants