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

Dynamic tree problem, children functions not executed properly #202

Open
nemanjan00 opened this issue Sep 30, 2020 · 1 comment
Open

Dynamic tree problem, children functions not executed properly #202

nemanjan00 opened this issue Sep 30, 2020 · 1 comment

Comments

@nemanjan00
Copy link

This is sample code that does not work as expected.

First node does not want to expand.

This seem to fix it:

nemanjan00@f1432f4

It sounds to me like somewhere children is used instead of childrenContent

const blessed = require('blessed');
const contrib = require('blessed-contrib');

const screen = blessed.screen();

const tree = contrib.tree();

const recur = (depth) => {
	depth = depth || 1

	if(depth == 10) {
		return {}
	}

	return {
		"test": {
			children: (() => recur(depth + 1))
		}
	};
}

tree.setData({
	extended: true,
	children: () => recur()
});


screen.append(tree);

tree.focus();

screen.key(['escape', 'q', 'C-c'], function(ch, key) {
	return process.exit(0);
});

screen.render();
@nemanjan00
Copy link
Author

Ok, I think I did figure out why it is not expanding, Since function is called on every render, new instance of object is generated and expand is not saved. Expand needs either to be saved in different structure or children need to be reused (either by library user or by library)

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

1 participant