From e868b2c5d3898e2cd7fe8b6e5c76aed352674fc4 Mon Sep 17 00:00:00 2001 From: Jake/Rads Date: Mon, 27 Jun 2022 16:53:52 +0200 Subject: [PATCH] fix(dashboard): card navigation randomly breaking because svelte randomly sets bind:this in an array to null for an entire page, for reasons I do not know, im just doing it directly with ids --- dashboard/src/lib/list/CardsList.svelte | 30 ++++++++++++------------- dashboard/src/lib/list/List.svelte | 2 +- dashboard/src/pages/Group.svelte | 2 +- dashboard/src/pages/Member.svelte | 2 +- dashboard/src/pages/Random.svelte | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/dashboard/src/lib/list/CardsList.svelte b/dashboard/src/lib/list/CardsList.svelte index 54903359..5e13eaa2 100644 --- a/dashboard/src/lib/list/CardsList.svelte +++ b/dashboard/src/lib/list/CardsList.svelte @@ -22,12 +22,11 @@ export let isMainDash: boolean; export let itemsPerPage: number; export let currentPage: number; + export let fullLength: number; export let openByDefault = false; $: indexStart = itemsPerPage * (currentPage - 1); - - let cardIndexArray = []; function getItemLink(item: Member | Group): string { let url: string; @@ -47,13 +46,14 @@ let el; if (event.key === "ArrowDown") { - if (index + 1 < indexStart + itemsPerPage) el = cardIndexArray[index + 1]; - else el = cardIndexArray[indexStart]; + if (index + 1 < indexStart + itemsPerPage && index + 1 < fullLength) el = document.getElementById(`${itemType}-card-${index + 1}`); + else el = document.getElementById(`${itemType}-card-${indexStart}`); } if (event.key === "ArrowUp") { - if (index - 1 >= indexStart) el = cardIndexArray[index - 1]; - else el = cardIndexArray[indexStart + itemsPerPage - 1]; + if (index - 1 >= indexStart) el = document.getElementById(`${itemType}-card-${index - 1}`); + else if (fullLength <= indexStart + itemsPerPage) el = document.getElementById(`${itemType}-card-${fullLength - 1}`); + else el = document.getElementById(`${itemType}-card-${indexStart + itemsPerPage - 1}`); } if (el) { @@ -110,9 +110,9 @@ {#each list as item, index (item.id + index)}

-

@@ -142,10 +142,10 @@ {:else if openByDefault || settings.accessibility.expandedcards} {#each list as item, index (item.id + index)} -