From cd406152a536123c08409a1195a2a3e7b688483a Mon Sep 17 00:00:00 2001 From: fcppddl <112799728+fcppddl@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:05:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E6=97=B6=E8=A7=A6=E5=8F=91=E9=94=AE=E7=9B=98?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=8A=A5=E9=94=99=20(#3026)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复选项禁用时触发键盘事件报错 * chore: md提交 --------- Co-authored-by: wanjinping --- .changeset/pretty-trains-bake.md | 6 ++++++ packages/ui/tree/src/hooks/use-focus.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/pretty-trains-bake.md 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: 选中界面上一层节点,如果展开,则收起