From 3cf32817f59fed670662bd57cb0ab2c2bfcabaa7 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Mon, 2 Dec 2024 11:02:26 -0800 Subject: [PATCH] rx.upload must include _var_data from props str-casting the dropzone arguments removed any VarData they depended on, like the state context. update test_upload to include passing a prop from a state var --- reflex/components/core/upload.py | 13 ++++++++----- tests/integration/test_upload.py | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py index 33dfae40f..87488d98a 100644 --- a/reflex/components/core/upload.py +++ b/reflex/components/core/upload.py @@ -293,13 +293,15 @@ class Upload(MemoizationLeaf): format.to_camel_case(key): value for key, value in upload_props.items() } - use_dropzone_arguments = { - "onDrop": event_var, - **upload_props, - } + use_dropzone_arguments = Var.create( + { + "onDrop": event_var, + **upload_props, + } + ) left_side = f"const {{getRootProps: {root_props_unique_name}, getInputProps: {input_props_unique_name}}} " - right_side = f"useDropzone({str(Var.create(use_dropzone_arguments))})" + right_side = f"useDropzone({str(use_dropzone_arguments)})" var_data = VarData.merge( VarData( @@ -307,6 +309,7 @@ class Upload(MemoizationLeaf): hooks={Hooks.EVENTS: None}, ), event_var._get_all_var_data(), + use_dropzone_arguments._get_all_var_data(), VarData( hooks={ callback_str: None, diff --git a/tests/integration/test_upload.py b/tests/integration/test_upload.py index fe8ebb4d7..3d6c53721 100644 --- a/tests/integration/test_upload.py +++ b/tests/integration/test_upload.py @@ -23,6 +23,7 @@ def UploadFile(): _file_data: Dict[str, str] = {} event_order: List[str] = [] progress_dicts: List[dict] = [] + disabled: bool = False async def handle_upload(self, files: List[rx.UploadFile]): for file in files: @@ -56,6 +57,7 @@ def UploadFile(): rx.button("Select File"), rx.text("Drag and drop files here or click to select files"), ), + disabled=UploadState.disabled, ), rx.button( "Upload",