From 34d9e074fa7afa2c227c7ee428a01ac9dbfb3e3c Mon Sep 17 00:00:00 2001 From: Paul Pestov <10750176+paulpestov@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:42:22 +0100 Subject: [PATCH] fix: don't change value of nav button labels when new item has not loaded yet --- src/components/header/NavBar.vue | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/header/NavBar.vue b/src/components/header/NavBar.vue index b7eb845d..843bdca4 100644 --- a/src/components/header/NavBar.vue +++ b/src/components/header/NavBar.vue @@ -63,15 +63,19 @@ const hasNext = computed(() => { const [nextPageLabel, previousPageLabel, nextDocumentLabel, previousDocumentLabel]: string[] = getNavButtonsLabels(configStore.config) -const nextButtonLabel = computed(() => ( -itemIndex.value === manifest.value.sequence.length - 1 - ? `${nextDocumentLabel}` - : `${nextPageLabel}`)); +const nextButtonLabel = computed((lastValue: string) => { + if (itemIndex.value === -1) return lastValue; + + return itemIndex.value === manifest.value.sequence.length - 1 + ? `${nextDocumentLabel}` + : `${nextPageLabel}`; +}); -const prevButtonLabel = computed(() => (itemIndex.value === 0 - ? `${previousDocumentLabel}` - : `${previousPageLabel}`)); +const prevButtonLabel = computed((lastValue: string) => { + if (itemIndex.value === -1) return lastValue; + return itemIndex.value === 0 ? `${previousDocumentLabel}` : `${previousPageLabel}`; +}); function prev() { const prevIndex = itemIndex.value - 1;