Hi all,
I’m building a shiny.express app where users can upload a file, make some modifications, and then download the result. I’d like the download button to be disabled by default and only become enabled after a file has been uploaded.
However, using update_action_button() to control the button’s state doesn’t seem to have any effect.
Do I miss something or is there an alternative method I should use?
Here’s a minimal example that reproduces the issue:
from shiny.express import input, render, ui
from shiny import reactive
import pandas as pd
# UI
ui.input_file(
"csv_file",
"Upload CSV file:",
multiple=False,
accept=".csv"
)
@render.download(filename="download.csv")
def download_csv():
file = input.csv_file()
if not file:
yield "No CSV file uploaded."
return
# Read uploaded file
df = pd.read_csv(file[0]["datapath"])
# Yield the CSV content as a string
yield df.to_csv(index=False)
@reactive.effect
def _():
ui.update_action_button("download_csv", disabled=not input.csv_file())