diff --git a/.changeset/pretty-trains-bake.md b/.changeset/pretty-trains-bake.md new file mode 100644 index 000000000..0a35bbdf7 --- /dev/null +++ b/.changeset/pretty-trains-bake.md @@ -0,0 +1,6 @@ +--- +"@hi-ui/tree": patch +"@hi-ui/hiui": patch +--- + +fix(tree): 选项禁用时触发键盘事件报错(#3025) diff --git a/packages/ui/tree/src/hooks/use-focus.ts b/packages/ui/tree/src/hooks/use-focus.ts index 5e7958229..6a15efc59 100644 --- a/packages/ui/tree/src/hooks/use-focus.ts +++ b/packages/ui/tree/src/hooks/use-focus.ts @@ -86,7 +86,7 @@ export const useFocus = ( } const focusNode = transitionData[focusedIndex] - const eventNode = getTreeNodeEventData(focusNode, getTreeNodeRequiredProps(focusNode.id)) + const eventNode = getTreeNodeEventData(focusNode, getTreeNodeRequiredProps(focusNode?.id)) switch (evt.keyCode) { // Left: 选中界面上一层节点,如果展开,则收起