TanStack / table

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
https://tanstack.com/table
MIT License
24.49k stars 3.03k forks source link

`autoResetPageIndex` seems to be default true when `manualPagination=true`, is not expectd as docs saying #5611

Closed slow-groovin closed 2 weeks ago

slow-groovin commented 2 weeks ago

TanStack Table version

v8.17.3

Framework/Library version

Vue v8.17.3

Describe the bug and the steps to reproduce it

codes

  1. table options
    options.onPaginationChange = onUpdatePageState
    options.rowCount = props.rowCount
  2. onPaginationChange
    function onUpdatePageState(updater: Updater<PageState>) {
    const oldValue=_.clone(pagination.value)
    valueUpdater(updater, pagination)
    if(!_.isEqual(oldValue,pagination.value)){
    emits('onPaginationUpdate', pagination.value.pageIndex, pagination.value.pageSize)
    }
    }
  3. emit call function
    function paginationChangeQuery(i:number,n:number){
    console.log('call',i,n)
    // debugger
    data.value=dataAll.slice(i*n,i*n+n)
    }
  4. change pageIndex action
    <Button
            v-for="pageNumber in [1,2,3,4]"
            @click="props.table.setPageIndex(pageNumber- 1)"
          >

    behavior

  5. when setPageIndex, it will call onPaginationChange twice, the log is

    call 3 10
    call 0 10

    first log is within expectations, second log seems reset the pagination, and cause the manual pagination failed.

  6. try set autoResetPageIndex:false , it will functioning properly
    call 3 10

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

holdon

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

slow-groovin commented 2 weeks ago

caused by my negligence