Config for figure object not updating correctly

I am trying to have it that when a user creates a figure, the title of that figure is then used to assign the name that is used when the image is downloaded.

@app.callback(
    dash.dependencies.Output("graph", "config"),
                  [Input("graph","figure")])
def set_graph_name(figure_value):
    Title = figure_value["layout"].get("title") or ""
    dict_config = {"modeBarButtonsToRemove": buttons_to_remove,"displaylogo": False, 'toImageButtonOptions':download_ratio}
    dict_config['toImageButtonOptions']['filename'] =  Title.replace(" ", "_")
    return dict_config

However for some reason the name that is used for the download is usually the previous title that it was given.

So if user says Title = “hello” then the page will download the image with newplot.png. If it is changed again it will download with the title hello.png.

I have been told that the issue is around the communication between the front end and the back end.

When the config is updated this is not considered to be a good reason for the front end to be updated. If any other change is made to the graph then it downloads with the right title.

Any help would be hugely appreciated, many thanks