Focus and keyboard navigation do not work in search results when disabled parents
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
調査の方向性
issue に記載されているエントリポイント getFirstMatchingNode から始め、リンクされた CodeSandbox を使って動作を再現し、無効化された親と有効化された親のケースを比較します。一致する有効な子要素がフォーカスを受け取り、Enter で選択できることを確認し、リポジトリに関連するテストがある場合は回帰テストのカバレッジを追加または更新します。
索引モデルが issue の本文から書いたものです。
説明
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;
Demo after;
Initially created as an antD issue
Please let me know if I can provide any more information
- 主要言語
- TypeScript
- スター
- 312
- フォーク
- 204
- 平均マージ
- 37分
- マージ済み PR(30日)
- 1
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
react-component/tree-select のほかの issue
-
treeTitleRender 回显时函数中的targetItem中只有value属性,只return targetItem.label时有效,return 拼接数据只能获取到value属性 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
react-component/tree-select#528 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
react-component/tree-select#485 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
react-component/tree-select#466 ·
-
DFS这里是否能调整为尾递归 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
react-component/tree-select#454 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
react-component/tree-select#437 · リアクション 3 件 ·
react-component/tree-select の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
TanStack/tanstack.com#1293 ·