Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions components/tree/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,16 @@ const propTypes = {
* Styles to be added to the top-level `ul` element. Useful for `overflow:hidden`.
*/
listStyle: PropTypes.object,
/**
* Indicate whether a tree node is selectable
*/
treeNodeSelectable: PropTypes.boolean,
};

const defaultProps = {
assistiveText: {},
getNodes: (node) => node.nodes,
treeNodeSelectable: true,
};

/* Flattens hierarchical tree structure into a flat array. The
Expand Down Expand Up @@ -189,6 +194,9 @@ class Tree extends React.Component {
}

handleSelect = ({ event, data, clearSelectedNodes, fromFocus }) => {
if (!this.props.treeNodeSelectable) {
return;
}
// When triggered by a key event, other nodes should be deselected.
if (clearSelectedNodes) {
// TODO: This bad design. This is state modfication. State should be changed via setState only.
Expand Down