|
27 | 27 | </li>
|
28 | 28 | <template v-if="currentPage.totalCount > currentPage.edges.length">
|
29 | 29 | <li>
|
| 30 | + <!-- Reset at if coming from second page --> |
30 | 31 | <ActionButtonToggle
|
31 | 32 | :theme="theme"
|
32 | 33 | :aria-label="t('previous')"
|
33 |
| - :disabled="!currentPage.pageInfo.hasPreviousPage" |
| 34 | + :disabled="!pageInfo?.hasPreviousPage" |
34 | 35 | round=":sm-inv"
|
35 |
| - @click="currentPage && setAt(currentPage.pageInfo?.previousCursor)" |
| 36 | + @click="setAt(pageNumber > 2 ? pageInfo?.previousCursor : undefined)" |
36 | 37 | >
|
37 | 38 | <IconFa name="arrow-left" />
|
38 | 39 | <IconFa name="arrow-left" regular />
|
|
43 | 44 | <ActionButtonToggle
|
44 | 45 | :theme="theme"
|
45 | 46 | :aria-label="t('next')"
|
46 |
| - :disabled="!currentPage.pageInfo.hasNextPage" |
| 47 | + :disabled="!pageInfo?.hasNextPage" |
47 | 48 | round=":sm-inv"
|
48 |
| - @click="currentPage && setAt(currentPage.pageInfo?.nextCursor)" |
| 49 | + @click="setAt(pageInfo?.nextCursor)" |
49 | 50 | >
|
50 | 51 | <span class="--hidden-full:sm-inv">{{ t("next") }}</span>
|
51 | 52 | <IconFa name="arrow-right" />
|
|
99 | 100 | const { first: defaultFirst } = inject<iPluginOptions>("xamu") || {};
|
100 | 101 | const { t } = useHelpers(useI18n);
|
101 | 102 |
|
102 |
| - /** |
103 |
| - * Set at |
104 |
| - * preserve route/pagination |
105 |
| - * |
106 |
| - * @replace |
107 |
| - */ |
108 |
| - function setAt(at?: string | number) { |
109 |
| - emit("update:model-value", { ...props.modelValue, at }); |
110 |
| - } |
| 103 | + const pageInfo = computed(() => props.currentPage?.pageInfo); |
| 104 | + const pageNumber = computed(() => props.currentPage?.pageInfo?.pageNumber || 0); |
111 | 105 |
|
112 | 106 | /**
|
113 | 107 | * PaginationSimple first model
|
|
131 | 125 |
|
132 | 126 | return pagesText;
|
133 | 127 | });
|
| 128 | +
|
| 129 | + /** |
| 130 | + * Set at |
| 131 | + * preserve route/pagination |
| 132 | + * |
| 133 | + * @replace |
| 134 | + */ |
| 135 | + function setAt(at?: string | number) { |
| 136 | + emit("update:model-value", { ...props.modelValue, at }); |
| 137 | + } |
134 | 138 | </script>
|
0 commit comments