Black Lives Matter. Please consider donating to Black Girls Code today.

modeBarButtonsToAdd doesn't appear to be working as intended

Hello, It appears that when I attempt to add the ‘select2d’ button to the modebar on a ScatterMapBox I get an error stating “must provide button ‘name’ in button config”. Not sure where this issue is coming from to be honest. Can anyone point out what I’m missing here?

Here is the Code

app.layout = html.Div(
    [
        html.Div(
            [
                dcc.Graph(id='map',
                          figure=
                          {
                            'data': [go.Scattermapbox()],
                            'layout': go.Layout(
                                paper_bgcolor='#f9f9f9',
                                plot_bgcolor='#f9f9f9',
                                dragmode='select',
                                mapbox=dict(bearing=0, 
                                            zoom=14,
                                            style='satellite',
                                            accesstoken=[redacted])
                                    )
                          },
                          config={'modeBarButtonsToAdd': ["select2d"]}
                )
            ], className="pretty_container"
        ),
    ]
)

Edit: I should clarify that modeBarButtonstoRemove seems to work just fine. I can remove any buttons I want from the modebar. Since syntactically these actions are similar I don’t see why adding buttons would fail. I also wanted to include a photo of the error. If I need to add anymore code please let me know.

Edit2: So I’ve been trying different things and I’ve noticed that if I pass an empty list

config={'modeBarButtonsToAdd': []}

Then the graph will render, just without the button I want. But as soon as I try to add a button that is there by default, pan2d, then it throws the same "must provide button ‘name’ in button config’ error. Somehow modeBarButtonsToAdd doesn’t know any of the button names I think. Does anyone know how to I can fix this? Should this be reported as bug or something?

I’ve found the solution. I feel silly but I honestly thought that modeBarButtonsToAdd could just add a default button to the modebar, but I was incorrect. It actually allows you to add custom buttons or something? I’m not sure. But I was able to get what I wanted by doing this.

config={'modeBarButtons': [['pan2d','select2d']]} 

This allows me to have the select option on the graph even if there are no points on it. Which is all I wanted.