Skip to content

Commit 717d5c5

Browse files
committed
Modified a condition to shorten it
1 parent 48db6b0 commit 717d5c5

File tree

1 file changed

+2
-5
lines changed
  • packages/applet/src/modules/components

1 file changed

+2
-5
lines changed

packages/applet/src/modules/components/index.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,11 @@ function getNearestPreviousNode(parentId: string) {
400400
401401
function getNearestNextNode() {
402402
const linkedListTree = treeNodeLinkedList.value
403-
const activeItemListIndex = [...linkedListTree]
404-
.map((arr, index) => ({ arr, index }))
405-
.reverse()
406-
.find(({ arr }) => arr?.includes(activeComponentId.value))
407-
?.index as number
403+
const activeItemListIndex = [...linkedListTree].findLastIndex(arr => arr?.includes(activeComponentId.value))
408404
409405
if (activeItemListIndex === -1)
410406
return activeComponentId.value
407+
411408
const arr1 = linkedListTree[activeItemListIndex]
412409
const arr2 = linkedListTree[activeItemListIndex + 1]
413410

0 commit comments

Comments
 (0)