Handle Var passed to rx.toast
If the user provides a `Var` for `message` then apply it as `props["title"]` to avoid a var operations error.
This commit is contained in:
parent
681b616000
commit
85a9cef377
@ -251,7 +251,9 @@ class Toaster(Component):
|
|||||||
"Toaster component must be created before sending a toast. (use `rx.toast.provider()`)"
|
"Toaster component must be created before sending a toast. (use `rx.toast.provider()`)"
|
||||||
)
|
)
|
||||||
toast_command = f"{toast_ref}.{level}" if level is not None else toast_ref
|
toast_command = f"{toast_ref}.{level}" if level is not None else toast_ref
|
||||||
if message == "" and ("title" not in props or "description" not in props):
|
if isinstance(message, Var):
|
||||||
|
props.setdefault("title", message)
|
||||||
|
elif message == "" and ("title" not in props and "description" not in props):
|
||||||
raise ValueError("Toast message or title or description must be provided.")
|
raise ValueError("Toast message or title or description must be provided.")
|
||||||
if props:
|
if props:
|
||||||
args = LiteralVar.create(ToastProps(component_name="rx.toast", **props)) # type: ignore
|
args = LiteralVar.create(ToastProps(component_name="rx.toast", **props)) # type: ignore
|
||||||
|
Loading…
Reference in New Issue
Block a user