From 4eec0eb1887b565b969f2b34f4a34bdc751de708 Mon Sep 17 00:00:00 2001 From: spade5 <chenhao8@360.cn> Date: Tue, 12 Jul 2022 15:24:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20useKeyboard=20=E6=9F=A5=E8=AF=A2=20activ?= =?UTF-8?q?eIndex=20=E7=BC=BA=E5=B0=91=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/OptionList/useKeyboard.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OptionList/useKeyboard.ts b/src/OptionList/useKeyboard.ts index 19070baf..0327fdfa 100644 --- a/src/OptionList/useKeyboard.ts +++ b/src/OptionList/useKeyboard.ts @@ -32,7 +32,8 @@ export default ( option => option[fieldNames.value] === activeValueCells[i], ); - if (nextActiveIndex === -1) { + const subOption = currentOptions = currentOptions[activeIndex]?.[fieldNames.children]; + if (!subOption?.length || nextActiveIndex === -1) { break; } @@ -40,7 +41,7 @@ export default ( mergedActiveIndexes.push(activeIndex); mergedActiveValueCells.push(activeValueCells[i]); - currentOptions = currentOptions[activeIndex][fieldNames.children]; + currentOptions = subOption; } // Fill last active options