-
Notifications
You must be signed in to change notification settings - Fork 2
DX-6569 dont allow extracting from nested list children #2
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
Conversation
src/index.js
Outdated
@@ -54,6 +55,7 @@ export default class JSONTree extends React.Component { | |||
PropTypes.object | |||
]).isRequired, | |||
hideRoot: PropTypes.bool, | |||
isNotAllowExtractNestedItemOfList: PropTypes.bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a generic library. It shouldn't know about our use case.
Instead, change this to maxClickableNodeDepth.
We will set it to 1 in our code if the data is a list.
src/index.js
Outdated
@@ -97,6 +99,8 @@ export default class JSONTree extends React.Component { | |||
<JSONNode | |||
{...{ postprocessValue, hideRoot, styling, ...rest }} | |||
keyPath={hideRoot ? [] : keyPath} | |||
isRootTypeOfNodeIsArray={objType(value) === 'Array'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this here. We should check this in our code, and set maxClickableNodeDepth.
remove isRootTypeOfNodeIsArray
src/JSONNestedNode.js
Outdated
@@ -106,6 +108,16 @@ export default class JSONNestedNode extends React.Component { | |||
|
|||
shouldComponentUpdate = shouldPureComponentUpdate; | |||
|
|||
isShouldExtract = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, make handleNodeClick and handleMouseOver do nothing and not stopPropagation if their keypath is deeper than maxClickableNodeDepth.
src/JSONNestedNode.js
Outdated
@@ -147,8 +137,10 @@ export default class JSONNestedNode extends React.Component { | |||
itemType, | |||
createItemString(data, collectionLimit) | |||
); | |||
|
|||
const stylingArgs = [keyPath, nodeType, expanded, expandable, this.isShouldExtract()]; | |||
const hover = maxClickableNodeDepth && keyPath.length > maxClickableNodeDepth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just use this.state.hover, because if keyPath.length > maxClickableNodeDepth, then state.hover will never be set.
No description provided.