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

Adding custom attribute/props to nodes #93

Open
ciaoben opened this issue Jun 12, 2018 · 4 comments
Open

Adding custom attribute/props to nodes #93

ciaoben opened this issue Jun 12, 2018 · 4 comments

Comments

@ciaoben
Copy link

ciaoben commented Jun 12, 2018

Thanks for this great library.
I am using it in a project where I need to click not only on the label of the node, but on the node itself (the <li class="rct-node"></li>) or at least being able to add custom attribute to each node so I can use data attribute and capture the click inside the node and use those attributes to trigger my logic.

Is there a way to do this? I want to avoid creating a fork of it considering that it is constantly maintained and improved.

@ciaoben ciaoben changed the title Add custom attribute/props to nodes Adding custom attribute/props to nodes Jun 12, 2018
@jakezatecky
Copy link
Owner

jakezatecky commented Jun 23, 2018

Currently there is no way to do this. May I ask what use case you have for clicking the entire node? Naturally, having something that records the click on the entire node itself would have it trigger if any child is also clicked. It would also trigger if you happen to click way away from the label, to the right, because of how the nodes fill up the remaining container space.

While I would not be entirely opposed to having custom attributes, there are so many DOM nodes that make up a checkbox node that it would not be practical to have a custom property area for every one of them (e.g. nodeAttributes, labelAttributes, checkboxAttributes, etc.).

@ciaoben
Copy link
Author

ciaoben commented Jun 26, 2018

Thanks for the answer. Yeah, probably my use case is pretty specific and to be honest I am using this plugin to make the sidebar of a web application so it is not the use case you thought about when you design it.

Here is an example of my component based on yours:
image

Right now to select a menu item, I need to click on the text. This behavior is not ideal as the user always try to click on the whole body of each item.

Probably will need to fork it and continue on a separate road considering that it is not the main use case for the library.

@jonhill13
Copy link

@jakezatecky We need to allow users to tab through nodes. Any thoughts?

@jakezatecky
Copy link
Owner

@jonhill13 The ability to tab through nodes is a feature I would like to add to this component eventually (likely part of #24). I could simply add a bunch of tabindex attributes to the resulting HTML nodes, but that would not be sufficient for full tab-based access.

I definitely would welcome a PR supporting tabbing through nodes, as it likely would have very little impact on other parts of the component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants