Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ Data for rendering the tree select items. The object requires the following stru
expanded, // optional: If true, the node is expanded (children of children nodes are not expanded by default unless children nodes also have expanded: true).
className, // optional: Additional css class for the node. This is helpful to style the nodes your way
tagClassName, // optional: Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node.
disableNavitaion, //optional: Allows to slip the keyboard navigation on this node.
actions, // optional: An array of extra action on the node (such as displaying an info icon or any custom icons/elements)
dataset, // optional: Allows data-* attributes to be set on the node and tag elements
isDefaultValue, // optional: Indicate if a node is a default value. When true, the dropdown will automatically select the node(s) when there is no other selected node. Can be used on more than one node.
Expand Down
21 changes: 21 additions & 0 deletions src/index.keyboardNav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ test('other key presses does not open dropdown on keyboardNavigation', t => {
})
})

test('should skip navigation on a node with disableNavigation = true', t => {
const tree = [
{
label: 'All data',
value: '0',
disableNavigation: true,
},
{
label: 'iWay',
value: '1',
},
{
label: 'KDB',
value: '2',
},
]
const wrapper = mount(<DropdownTreeSelect data={tree} />)
triggerOnKeyboardKeyDown(wrapper, ['ArrowDown', 'ArrowDown'])
t.deepEqual(wrapper.find('li.focused').text(), 'KDB')
})

test('can navigate and focus child on keyboardNavigation', t => {
const wrapper = mount(<DropdownTreeSelect data={tree} />)
triggerOnKeyboardKeyDown(wrapper, [
Expand Down
2 changes: 1 addition & 1 deletion src/tree-manager/nodeVisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getVisibleNodes = (tree, getItemById, markSubTreeOnNonExpanded) =>
if (markSubTreeOnNonExpanded && node._children && node._children.length && node.expanded !== true) {
markSubTreeVisited(node, visited, getItemById)
}
return !node.hide
return !node.hide && !node.disableNavigation
})

const nodeVisitor = {
Expand Down