reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Buttons stop working after a sequence

Open SebatinCx opened this issue 1 year ago • 4 comments

Describe the bug A clear and concise description of what the bug is. I was trying to download in production mode and the buttons stopped working.

To Reproduce Steps to reproduce the behavior: click the "guardar" button, then "descargar" and click the "guardar" button again and all the buttons on my page stop working.

  • Code:
class State(rx.State): 
   
   path_bajar = ""
   
   def upload_file(self):
       # Define el número de filas y columnas para el DataFrame
       filas = 10
       columnas = 5
       
       # Crea un DataFrame con datos aleatorios
       df = pd.DataFrame({
           f'Columna {i+1}': [random.randint(1, 100) for _ in range(filas)] 
           for i in range(columnas)
       })
       
       # Crea el nombre del archivo Excel
       nombre_archivo = "datos_aleatorios.xlsx"
       
       outfile = rx.get_upload_dir() / nombre_archivo
       
       # Guarda el DataFrame en un archivo Excel
       df.to_excel(outfile, index=False)
       
       print(f"Se creó el archivo Excel: {nombre_archivo}")
       

@rx.page("/")
def index() -> rx.Component:
   return rx.center(
       rx.button(
           "Guardar",
           on_click=State.upload_file(),
           ),
       
       rx.button(
           "Descargar",
           on_click=rx.download(url = rx.get_upload_url("datos_aleatorios.xlsx")),
                               
           ),
       )        
app = rx.App()
app.add_page(index)

Expected behavior A clear and concise description of what you expected to happen.

After reloading the page, I can repeat the process of saving and downloading files, but the buttons become unresponsive again. No error messages are reported in the browser console. Also happens with "reflex run"

Specifics (please complete the following information):

  • Python Version: 3.10
  • Reflex Version: 5.3, 5.2, 5.1, 5.0, 4.9
  • OS: Ubuntu
  • Browser (Optional):Brave, Microsoft Edge

SebatinCx avatar Jun 08 '24 05:06 SebatinCx

Hi thanks for reporting.

This is a known bug, but we have yet to find the exact reason it happens (after downloading, it seems to cause issue with the WS in some case).

Will need to investigate more to figure out what's happening.

Lendemor avatar Jun 08 '24 09:06 Lendemor

Related PR: https://github.com/reflex-dev/reflex/pull/3041

We didn't merge that PR because it would cause other unwanted side effects.

Lendemor avatar Jun 08 '24 09:06 Lendemor

I was reviewing the PR: #3041, and with the .text file that is made the example that works opens on the page as the tab and shows what the text contains. But I can't guarantee that it really works because I tried to do it with the excel file in the same way that they presented the example and it also stops working

SebatinCx avatar Jun 08 '24 16:06 SebatinCx

Any update with this issue of buttons becoming unresponsive after downloading? update: the code changes in PR #3041 fixed the issue for me. Hoping unwanted side effects aren't too serious 😬

amballa avatar Sep 20 '24 20:09 amballa

I believe this is fixed now.

adhami3310 avatar Feb 05 '25 00:02 adhami3310