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

[Feature Request] onCheck/onClick/onExpand returns object w/ same data provided at invocation #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MaxwellKendall
Copy link

@MaxwellKendall MaxwellKendall commented Mar 31, 2020

It would be really nice if we could do the following:

onCheck = (newChecked, selectedNode) => {
  const { requiredKey } = selectedNode;
  const { myCustomKey } = selectedNode.extraKeys;
  // do something with myCustomKey
}
<CheckboxTree nodes=[{ ...allRequiredKeys, ...myCustomKeys }] onCheck={this.onCheck}/>

At the moment, only the required keys are returned and therefore myCustomKey above is undefined.

flattenNodes returns an object with a new shape.

The goal here is to pass the caller of CheckboxTree -- onClick/onExpand/onCheck -- a
 node w/ the same data passed to it at invocation
 inside the nodes array.

We now return all properties of the object passed at invocation under the keyspace
"extraKeys": { ...node }
@MaxwellKendall MaxwellKendall changed the title [Feature Request] onCheck/onClick/onExpand returns node object w/ same data passed at invocation [Feature Request] onCheck/onClick/onExpand returns object w/ same data provided at invocation Mar 31, 2020
'disabled',
'treeDepth',
'index',
'extraKeys',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we actually should remove this line. Wasn't able to test this locally. Was getting an error on npm run examples and npm run test had some tests that appeared to be failing for me on the master branch w/o my changes.

Suggested change
'extraKeys',

@MaxwellKendall
Copy link
Author

@jakezatecky Can we get a review on this?

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

Successfully merging this pull request may close these issues.

2 participants