Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add active class #92

Closed
andyjamesn opened this issue Nov 29, 2023 · 1 comment
Closed

Add active class #92

andyjamesn opened this issue Nov 29, 2023 · 1 comment

Comments

@andyjamesn
Copy link

I am trying to add an active class to nodes on click.

I am using the stat.class within the click:node event. But I have to loop through all nodes to disable the active class before setting the node to active.

I am wondering if there a better way to do this?

const onClickNode = (stat) => {
    for (const stat of treeRef.value.statsFlat) {
        stat.class = '';
    }
    stat.class = 'active';
};
@phphe
Copy link
Owner

phphe commented Nov 30, 2023

let lastActive;
const onClickNode = (stat) => {
    if (lastActive) { 
lastActive.class = ''
}
    stat.class = 'active';
lastActive = stat
};

@phphe phphe closed this as completed Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants