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(ktable): remove next page clicked logic [KHCP-13030] #2352

Closed
wants to merge 12 commits into from
9 changes: 0 additions & 9 deletions src/components/KTable/KTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ const offsets: Ref<Array<any>> = ref([])
const hasNextPage = ref(true)
const isClickable = ref(false)
const hasInitialized = ref(false)
const nextPageClicked = ref(false)
const hasToolbarSlot = computed((): boolean => !!slots.toolbar || hasColumnVisibilityMenu.value)

/**
Expand Down Expand Up @@ -815,12 +814,6 @@ const fetchData = async () => {
if (props.paginationOffset) {
if (!res.pagination?.offset) {
offset.value = null

// reset to first page if no pagiantion data is returned unless the "next page" button was clicked
// this will ensure buttons display the correct state for cases like search
if (!nextPageClicked.value) {
page.value = 1
}
} else {
offset.value = res.pagination.offset
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t quite understand why we updated the offset here and then fixed it in the fetcher. Wouldn’t it make more sense to save res.pagination.offset into a variable like nextPageOffset and update the offset only when moving to the next page?

Copy link
Contributor

@2eha0 2eha0 Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have permission to push a branch, I modified it locally and verified that it seems to work
image


Expand All @@ -832,7 +825,6 @@ const fetchData = async () => {
hasNextPage.value = (res.pagination && 'hasNextPage' in res.pagination) ? res.pagination.hasNextPage : true
}

nextPageClicked.value = false
isInitialFetch.value = false

return res
Expand Down Expand Up @@ -1004,7 +996,6 @@ const emitTablePreferences = (): void => {

const getNextOffsetHandler = (): void => {
page.value++
nextPageClicked.value = true
}

const getPrevOffsetHandler = (): void => {
Expand Down