Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kpagination): ensure firstDetached consistency [KM-580] #2452

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/components/KPagination/KPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ const endCount = computed((): number => {
const pagesString = computed((): string => `${startCount.value} to ${endCount.value}`)
const pageCountString = computed((): string => ` of ${props.totalCount}`)
const currentlySelectedPage = computed((): number => props.currentPage ? props.currentPage : currPage.value)
const firstDetached = ref<boolean>(currentlySelectedPage.value >= fittingNeighbors.value + (sequentialItemsVisible.value + 1))

// Selected page, first page, last page, 2 placeholders and 2 * neighbors
const visiblePages = computed((): number => 5 + 2 * fittingNeighbors.value)
const firstDetached = ref<boolean>(currentlySelectedPage.value >= fittingNeighbors.value + (sequentialItemsVisible.value + 1) && pageCount.value > visiblePages.value)
const lastDetached = ref<boolean>(pageCount.value > (sequentialItemsVisible.value + 2) + (2 * fittingNeighbors.value))
const pagesVisible = ref<Array<number>>(getVisiblePages(
currentlySelectedPage.value,
Expand Down Expand Up @@ -348,9 +351,7 @@ const updatePage = (): void => {
forwardDisabled.value = lastEntry >= props.totalCount
backDisabled.value = currPage.value === 1
// The view will hold
// Selected page, first page, last page, 2 placeholders and 2 * neighbors
const visiblePages = 5 + 2 * fittingNeighbors.value
if (pageCount.value <= visiblePages) {
if (pageCount.value <= visiblePages.value) {
// All pages will fit in screen
firstDetached.value = false
lastDetached.value = false
Expand Down