From c1089fc8f989c227cf600d482cb0da536fd5d08a Mon Sep 17 00:00:00 2001 From: Elijah Ahianyo Date: Tue, 13 Feb 2024 19:58:48 +0000 Subject: [PATCH] [REF-1925] Accordion foreach fix (#2598) --- reflex/components/radix/primitives/accordion.py | 8 +++++--- reflex/components/radix/primitives/accordion.pyi | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py index 59aff2c6c..e927c99e1 100644 --- a/reflex/components/radix/primitives/accordion.py +++ b/reflex/components/radix/primitives/accordion.py @@ -339,7 +339,7 @@ class AccordionRoot(AccordionComponent): color_scheme: Var[LiteralAccentColor] # type: ignore # dynamic themes of the accordion generated at compile time. - _dynamic_themes: Var[dict] + _dynamic_themes: Var[dict] = Var.create({}) # type: ignore # The var_data associated with the component. _var_data: VarData = VarData() # type: ignore @@ -540,7 +540,9 @@ to { """ -def accordion_item(header: Component, content: Component, **props) -> Component: +def accordion_item( + header: Component | Var, content: Component | Var, **props +) -> Component: """Create an accordion item. Args: @@ -552,7 +554,7 @@ def accordion_item(header: Component, content: Component, **props) -> Component: The accordion item. """ # The item requires a value to toggle (use the header as the default value). - value = props.pop("value", str(header)) + value = props.pop("value", header if isinstance(header, Var) else str(header)) return AccordionItem.create( AccordionHeader.create( diff --git a/reflex/components/radix/primitives/accordion.pyi b/reflex/components/radix/primitives/accordion.pyi index 5e38a5516..c415431dc 100644 --- a/reflex/components/radix/primitives/accordion.pyi +++ b/reflex/components/radix/primitives/accordion.pyi @@ -625,7 +625,9 @@ class AccordionContent(AccordionComponent): """ ... -def accordion_item(header: Component, content: Component, **props) -> Component: ... +def accordion_item( + header: Component | Var, content: Component | Var, **props +) -> Component: ... class Accordion(SimpleNamespace): content = staticmethod(AccordionContent.create)