Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@render.download in Express modules #1856

Closed
julibeg opened this issue Feb 18, 2025 · 3 comments
Closed

@render.download in Express modules #1856

julibeg opened this issue Feb 18, 2025 · 3 comments

Comments

@julibeg
Copy link

julibeg commented Feb 18, 2025

Related to #1724 and #1726 but in Express.

@express.render.download() doesn't accept an id argument and also doesn't include the parent module's ns in the download link. Therefore, all download buttons created with an Express module download the same file. Consider the MWE below

from shiny.express import module, render, ui


@module
def card_with_download(input, output, session, label):
    with ui.card():
        ui.card_header(f"download {label}")

        @render.download(filename=f"test-{label}.txt", label=f"Download {label}")
        def download():
            yield f"Hi, we're in {label} file\n"


labels = list("ABCD")

for i, label in enumerate(labels):
    card_with_download(f"download_{label}", label=label)

Each of the buttons will download test-D.txt.

@gadenbuie
Copy link
Collaborator

Thanks for the report and for the very clear example. Can you check which version of Shiny you are using? You'll need to be using shiny v1.2.0 or later, which include the fixes mentioned and where your MWE seems to work. Here's a link to your example on shinylive.io where the downloads work as expected and shiny 1.2.0 is used.

@julibeg
Copy link
Author

julibeg commented Feb 18, 2025

Ah indeed! My bad, sorry! Upgrading to 1.2.1 fixed the issue. Thanks for the swift reply and many apologies!

@julibeg julibeg closed this as completed Feb 18, 2025
@gadenbuie
Copy link
Collaborator

No worries @julibeg, glad we figured it out 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants