Skip to content

Commit 4b35013

Browse files
authored
Merge pull request #80 from abdel-17/fix-end-key
fix: end key doesn't always focus last item
2 parents e4fce61 + 559ca08 commit 4b35013

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/big-ravens-cough.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-file-tree": patch
3+
---
4+
5+
fix: end key does not always focus the last item

packages/svelte-file-tree/src/lib/components/Tree.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,14 @@
243243
244244
function getLastVisibleItem() {
245245
let current = items[items.length - 1];
246-
if (current !== undefined && !current.visible) {
246+
if (current !== undefined) {
247247
while (current.parent !== undefined && !current.parent.expanded) {
248248
current = current.parent;
249249
}
250-
current = getPreviousVisibleItem(current);
250+
251+
if (!current.visible) {
252+
current = getPreviousVisibleItem(current);
253+
}
251254
}
252255
return current;
253256
}

0 commit comments

Comments
 (0)