fix allow_multiple & toggle_toggle conflict (#1175)
This commit is contained in:
parent
cd065946a9
commit
3c580bb41b
@ -16,7 +16,7 @@ class Accordion(ChakraComponent):
|
|||||||
allow_multiple: Var[bool]
|
allow_multiple: Var[bool]
|
||||||
|
|
||||||
# If true, any expanded accordion item can be collapsed again.
|
# If true, any expanded accordion item can be collapsed again.
|
||||||
allow_toggle: Var[bool] = True # type: ignore
|
allow_toggle: Var[bool]
|
||||||
|
|
||||||
# The initial index(es) of the expanded accordion item(s).
|
# The initial index(es) of the expanded accordion item(s).
|
||||||
default_index: Var[Optional[List[int]]]
|
default_index: Var[Optional[List[int]]]
|
||||||
@ -28,13 +28,23 @@ class Accordion(ChakraComponent):
|
|||||||
reduce_motion: Var[bool]
|
reduce_motion: Var[bool]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, *children, items=None, icon_pos="right", **props) -> Component:
|
def create(
|
||||||
|
cls,
|
||||||
|
*children,
|
||||||
|
items=None,
|
||||||
|
icon_pos="right",
|
||||||
|
allow_multiple: Optional[Var[bool]] = None,
|
||||||
|
allow_toggle: Optional[Var[bool]] = None,
|
||||||
|
**props
|
||||||
|
) -> Component:
|
||||||
"""Create an accordion component.
|
"""Create an accordion component.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
children: The children of the component.
|
children: The children of the component.
|
||||||
items: The items of the accordion component: list of tuples (label,panel)
|
items: The items of the accordion component: list of tuples (label,panel)
|
||||||
icon_pos: The position of the arrow icon of the accordion. "right", "left" or None
|
icon_pos: The position of the arrow icon of the accordion. "right", "left" or None
|
||||||
|
allow_multiple: The allow_multiple property of the accordion. (True or False)
|
||||||
|
allow_toggle: The allow_toggle property of the accordion. (True or False)
|
||||||
props: The properties of the component.
|
props: The properties of the component.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -58,6 +68,12 @@ class Accordion(ChakraComponent):
|
|||||||
AccordionPanel.create(panel),
|
AccordionPanel.create(panel),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# if allow_multiple is True, allow_toggle is implicitely used and does not need to be defined
|
||||||
|
if allow_multiple:
|
||||||
|
props.update({"allow_multiple": allow_multiple})
|
||||||
|
elif allow_toggle:
|
||||||
|
props.update({"allow_toggle": allow_toggle})
|
||||||
return super().create(*children, **props)
|
return super().create(*children, **props)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user