Skip to content

Commit 4eec0eb

Browse files
author
spade5
authored
fix: useKeyboard 查询 activeIndex 缺少判空
1 parent 37db73b commit 4eec0eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/OptionList/useKeyboard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ export default (
3232
option => option[fieldNames.value] === activeValueCells[i],
3333
);
3434

35-
if (nextActiveIndex === -1) {
35+
const subOption = currentOptions = currentOptions[activeIndex]?.[fieldNames.children];
36+
if (!subOption?.length || nextActiveIndex === -1) {
3637
break;
3738
}
3839

3940
activeIndex = nextActiveIndex;
4041
mergedActiveIndexes.push(activeIndex);
4142
mergedActiveValueCells.push(activeValueCells[i]);
4243

43-
currentOptions = currentOptions[activeIndex][fieldNames.children];
44+
currentOptions = subOption;
4445
}
4546

4647
// Fill last active options

0 commit comments

Comments
 (0)