You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Focus and keyboard navigation do not work in search results when disabled parents #652
When the tree select search is used, focus is given to the first element, users can press 'Enter' to select it or use 'up' and 'down' keys to navigate other search results
Disabled elements in the search should not be given focus, but if their children are enabled their children should still be focused in search results
What is actually happening?
Any element with a disabled parent somewhere in their hierarchy is not given focus when searching, 'Enter' key will select the first element in the tree instead
This is bad UX but also not good for accessibility
The demo shows two cases, one working (No disabled parents) and one broken (Disabled parent)
To show the component not working:
Click on the treeselect search
Search for '1' (Or '2', or '3')
The child element gets focus, pressing enter on keyboard does nothing
To show the component working as expected:
Click on the treeselect search
Search for '3' (Or '4', or '5')
The child element gets focus, pressing enter on keyboard selects element
Suggested code fix - even if a parent is disabled or not selectable, check children
// ========================== Get First Selectable Node ==========================constgetFirstMatchingNode=(nodes: EventDataNode<any>[]): EventDataNode<any>|null=>{for(constnodeofnodes){-if(node.disabled||node.selectable===false){-continue;-}--if(searchValue){-if(filterTreeNode(node)){-returnnode;-}-}else{-returnnode;-}+constisNodeSelectable=!node.disabled&&node.selectable!==false;++if(isNodeSelectable){+if(searchValue){+if(filterTreeNode(node)){+returnnode;+}+}else{+returnnode;+}+}if(node[fieldNames.children]){constmatchInChildren=getFirstMatchingNode(node[fieldNames.children]);if(matchInChildren){returnmatchInChildren;}}}returnnull;};
Activity