Dcc Graphs reset their relayout on tab change

I have a few dcc.Graphs that render histograms in my Dash app. In one instance, I have a callback that will update a shape on the histogram if the proper data exists in dcc.Loading.

Upon updating the callback, the relayout of the graph will look something like this:

{'shapes': [{'editable': True, 'label': {'text': ''}, 'xref': 'x', 'yref': 'y', 'layer': 'above', 'opacity': 1, 'line': {'color': '#444', 'width': 4, 'dash': 'solid'}, 'fillcolor': 'rgba(0,0,0,0)', 'fillrule': 'evenodd', 'type': 'rect', 'x0': 10.060903897849462, 'y0': 44456.17081925675, 'x1': 23.7705813172043, 'y1': -804.9102618243243}]}

however, on a tab change within the app, upon returning to the tab with the histogram, the relayout of the histogram has updated to:

{'autosize': True}

despite having no logic within the callbacks to allow a callback on a tab change. This continues to occur even by limiting callbacks to no include certain actions such as:

ctx.triggered_id != "tabs"

where tabs is the id of the tab set.

This is odd because the shape that is declared in the callback is not removed or modified in any way, but the change to the relayout affects a number of other linked callbacks erroneously.

Hi,

Can’t you just send an additional autosize: false, to mitigate this behavior?

by default the value is auto as described below:

responsive

A value equal to: true, false, ‘auto’. If True, the Plotly.js plot will be fully responsive to window resize and parent element resize event. This is achieved by overriding config.responsive to True, figure.layout.autosize to True and unsetting figure.layout.height and figure.layout.width. If False, the Plotly.js plot not be responsive to window resize and parent element resize event. This is achieved by overriding config.responsive to False and figure.layout.autosize to False. If ‘auto’ (default), the Graph will determine if the Plotly.js plot can be made fully responsive (True) or not (False) based on the values in config.responsive, figure.layout.autosize, figure.layout.height, figure.layout.width. This is the legacy behavior of the Graph component.
Needs to be combined with appropriate dimension / styling through the style prop to fully take effect.

Regards,
J