plotly / dash-core-components

OBSOLETE: now part of https://github.com/plotly/dash
https://dash.plotly.com
MIT License
271 stars 145 forks source link

dcc.Download doesn't open a file picker dialog on Safari #1012

Open kamatsuoka opened 6 months ago

kamatsuoka commented 6 months ago

MacOS Sonoma 14.2.1 Safari 17.2.1

dcc.Download doesn't open a file picker dialog on Safari. Instead, it just downloads the file to the ~/Downloads directory using the supplied filename. Example that works as expected on Chrome:

from dash import Dash, Input, Output, callback, dcc, html

app = Dash(__name__)
app.layout = html.Div(
    [
        html.Button("Download Text", id="btn-download-txt"),
        dcc.Download(id="download-text"),
    ]
)

@callback(
    Output("download-text", "data"),
    Input("btn-download-txt", "n_clicks"),
    prevent_initial_call=True,
)
def func(n_clicks):
    return dict(content="Hello world!", filename="hello.txt")

if __name__ == "__main__":
    app.run(debug=True)