[REF-1925] Accordion foreach fix (#2598)

This commit is contained in:
Elijah Ahianyo 2024-02-13 19:58:48 +00:00 committed by GitHub
parent d26ceb236d
commit c1089fc8f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -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(

View File

@ -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)