Modebar disappears when switching between 3d and 2d

Hello! I am having an issue where the modebar permanently disappears when go from a 3D scatter to a 2D scatter. The modebar is there when I switch to 3D from 2D but not when I switch back. The only way to recover it is by reloading the page.

I’ve included some code below that demonstrates this. You can see that even if I set displayModeBar to True.

import dash_html_components as html
import dash_core_components as dcc
from dash import Dash
from dash.dependencies import Input, Output
import plotly.graph_objects as go

app = Dash(__name__)
app.layout = html.Div([
    dcc.Graph(id='plot', config={'displayModeBar': True}),
    dcc.RadioItems(id='n-dims', options=[{'label': '2D', 'value': 2}, {'label': '3D', 'value': 3}], value=3)

    Output('plot', 'figure'),
    [Input('n-dims', 'value')]
def set_n_dims(n_dims):
    if n_dims == 2:
        return go.Figure(go.Scatter(x=[1, 2, 3], y=[2, 4, 8]))
        return go.Figure(go.Scatter3d(x=[1, 2, 3], y=[2, 2, 2], z=[2, 4, 8]))


Any idea what’s going on? Should I open an issue?


Here’s a gif of me using the code I listed. As you can see, after switching from 2D to 3D the modebar is gone.

I am almost certain this is bug in plotly.js.
Further discussion here: