Inverted time range (x-axis) after zoom

I’m creating a horizontal bar-plot as in a timeline (so, the x-axis is a timestamp, that is setup in plotly.js as layout.xaxis.type='date'). I also use layout.xaxis.autorange = true. The plot looks in principle fine:


But after zooming in and then double-clicking to zoom out, the x-scale becomes inverted:

How can I avoid this?

Also, the “reset axis” button on the modebar does not work, that rescales the graph this way:


Which is both in a wrong scale and inverted.

edit: I’m using plotly.js 2.12.1

I found the issue: I first create the graph with a given layout.xaxis.range = [xmin,xmax], and I set up general values xmin=2100 and xmax=2000 (a large value for xmin and a small value for xmax because they are used in a recursion with the x values of the traces to get new min and max). Then I add the data and layout modifications, including the xaxis.autorange, so I don’t pass a value for range in the new layout. But that is only updating the values with the new ones I pass, and it keeps the old ones. So, the range = [2100,2000] is still kept in the layout.