Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Focus and keyboard navigation do not work in search results when disabled parents

Offen
#652 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

@nrps9909 arbeitet bereits daran.

Seit 26.8.2026.

  • #684 von @nrps9909 — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
52/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
react, typescript

Rechercherichtung

Beginne mit dem im Issue beschriebenen Einstiegspunkt getFirstMatchingNode und reproduziere das Verhalten mithilfe der verknüpften CodeSandbox, wobei du die Fälle mit deaktiviertem übergeordnetem Element und aktiviertem übergeordnetem Element vergleichst. Überprüfe, dass passende aktivierte untergeordnete Elemente den Fokus erhalten und mit Enter ausgewählt werden können, und füge Regressionstests hinzu oder aktualisiere sie, falls das Repository entsprechende Tests enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

What is expected?

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

I am using master from this repo during testing

Steps to reproduce
I have a demo sandbox here made with AntD but exact behaviour comes from rc-tree-select, I can adjust the demo if needed: https://codesandbox.io/p/devbox/confident-resonance-8jv7cz

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 ==========================
const getFirstMatchingNode = (nodes: EventDataNode<any>[]): EventDataNode<any> | null => {
  for (const node of nodes) {
-    if (node.disabled || node.selectable === false) {
-      continue;
-    }
-
-    if (searchValue) {
-      if (filterTreeNode(node)) {
-        return node;
-      }
-    } else {
-      return node;
-    }
+    const isNodeSelectable = !node.disabled && node.selectable !== false;
+
+    if (isNodeSelectable) {
+      if (searchValue) {
+        if (filterTreeNode(node)) {
+          return node;
+        }
+      } else {
+        return node;
+      }
+    }
 
     if (node[fieldNames.children]) {
       const matchInChildren = getFirstMatchingNode(node[fieldNames.children]);
       if (matchInChildren) {
         return matchInChildren;
       }
     }
   }
   return null;
};

Demo before;

Image

Demo after;

Image

Initially created as an antD issue

Please let me know if I can provide any more information

Vorherrschende Sprache
TypeScript
Sterne
312
Forks
205
Ø Merge
37 Min.
Gemergte PRs (30 T.)
1

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus react-component/tree-select

Alle Issues in react-component/tree-select

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.