Skip to content

Recursive accordion fails #2633

Closed
Closed

Description

@vhunyad

Describe the bug
I would like to have a multilevel accordion, where the data comes from a dataset with IDs and parentIDs. I created a lambda function which filters for parent ID and calls a recursive helper function, but I got a python error saying exceeded the number of recursive cycles.
I have a workaround where I create separate functions for the different levels and they call each other in chain. These need to have different variable names in them in order not to collide. If these level functions have the same variable names, then it collides again, so I think the variable name is somehow reused in case of recursive calls.

To Reproduce
Level2 and Level3 need to have acc2 and acc3 variable in it in order not to collide.


def accordion_level1(account) -> rx.Component:
    return rx.accordion(
            rx.accordion_item(
                rx.text(account['name']),
                rx.accordion_panel(
                    rx.vstack(
                        rx.foreach(State.accordion,lambda acc1:rx.cond(acc1['aid_parent']==account['aid'],sidebar_level2(acc1))),
                    )
                ),
            ),

        )
.......
rx.vstack(
                rx.foreach(State.accordion,lambda acc:rx.cond(acc['aid_parent']=='0000',accordion_level1(acc))),
            )

Expected behavior
Be bale to create recursive multilevel accordion.

Screenshots
If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):
Python Version: 3.9.2
Reflex Version: 0.3.10
OS: Debian 11

Additional context

Activity

  1. linked a pull request that will close this issuefix recursive UI #4599on Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions