Skip to content

Commit 86d5b52

Browse files
authored
only access .name for upload component (#5515)
1 parent 7c328d5 commit 86d5b52

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

pyi_hashes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"reflex/components/core/helmet.pyi": "20afb0edbadb506d5cf374f153b3c6cf",
2121
"reflex/components/core/html.pyi": "faf9bb353ef4784e7f17ac97c93ef697",
2222
"reflex/components/core/sticky.pyi": "cdf17e6cd287e7300acd25669701d117",
23-
"reflex/components/core/upload.pyi": "4a44f34dc8e9450a383ee60a87a69e2c",
23+
"reflex/components/core/upload.pyi": "f9be9b74d97d841b53b963d8704d5809",
2424
"reflex/components/datadisplay/__init__.pyi": "87eae833026739e8d48a9891e185b3c2",
2525
"reflex/components/datadisplay/code.pyi": "3787ca724cae7b29d57ea03f981b8c22",
2626
"reflex/components/datadisplay/dataeditor.pyi": "23f777b8a46eff2afd95035dd5fc51a7",

reflex/components/core/upload.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
)
5151

5252

53-
def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
53+
def upload_file(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var:
5454
"""Get the file upload drop trigger.
5555
5656
This var is passed to the dropzone component to update the file list when a
@@ -62,7 +62,7 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
6262
Returns:
6363
A var referencing the file upload drop trigger.
6464
"""
65-
id_var = LiteralStringVar.create(id_)
65+
id_var = LiteralStringVar.create(id_) if not isinstance(id_, Var) else id_
6666
var_name = f"""e => setFilesById(filesById => {{
6767
const updatedFilesById = Object.assign({{}}, filesById);
6868
updatedFilesById[{id_var!s}] = e;
@@ -79,7 +79,7 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
7979
)
8080

8181

82-
def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var:
82+
def selected_files(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var:
8383
"""Get the list of selected files.
8484
8585
Args:
@@ -88,9 +88,9 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var:
8888
Returns:
8989
A var referencing the list of selected file paths.
9090
"""
91-
id_var = LiteralStringVar.create(id_)
91+
id_var = LiteralStringVar.create(id_) if not isinstance(id_, Var) else id_
9292
return Var(
93-
_js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => (f.path || f.name)) : [])",
93+
_js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => f.name) : [])",
9494
_var_type=list[str],
9595
_var_data=VarData.merge(
9696
upload_files_context_var_data, id_var._get_all_var_data()

0 commit comments

Comments
 (0)