Skip to content

Feature Request: Add prop to allow initially collapsed #39

@thorsent

Description

@thorsent

It's great that you can click on the tree nodes to expand them, but I'd like a way to specify that the tree should be initially collapsed (my use case is a log viewer with lots of objects in a big scrollable list).

In other words, I'd like to collapse the tree until the end user interacts with it.

I don't think there's a way to accomplish this with shouldExpandNode function, but I think you could add another prop called initialExpansionLevel to make this easy to control.

export interface Props extends React.AriaAttributes {
    data: Object | Array<any>;
    style?: StyleProps;
    shouldExpandNode?: (level: number, value: any, field?: string) => boolean; // programmatically override the expansion level
    clickToExpandNode?: boolean;
    initialExpansionLevel?: number // set the expansion level before the end user interacts with the tree: 0 = fully collapsed, -1 = fully expanded. Or set any number in-between to mimic shouldExpandNode Defaults to -1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions