Skip to content

Commit

Permalink
fix(comp:table): the size of pagination cannot be overridden (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm committed Feb 10, 2023
1 parent 760b5ac commit b647883
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/components/table/__tests__/table.spec.ts
Expand Up @@ -369,6 +369,10 @@ describe('Table', () => {
await wrapper.setProps({ pagination: { pageSize: 20 } })

expect(wrapper.find('tbody').findAll('tr').length).toBe(20)

await wrapper.setProps({ pagination: { size: 'sm' } })

expect(wrapper.find('.ix-table-pagination').classes()).toContain('ix-pagination-sm')
})

test('size work', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/table/src/composables/useDataSource.ts
Expand Up @@ -18,8 +18,8 @@ export function useDataSource(
props: TableProps,
mergedChildrenKey: ComputedRef<string>,
mergedGetKey: ComputedRef<GetKeyFn>,
activeSorters: ComputedRef<ActiveSorter[]>,
activeFilters: ComputedRef<ActiveFilter[]>,
activeSorters: Ref<ActiveSorter[]>,
activeFilters: Ref<ActiveFilter[]>,
expandedRowKeys: Ref<VKey[]>,
mergedPagination: ComputedRef<TablePagination | null>,
): DataSourceContext {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/table/src/composables/usePagination.ts
Expand Up @@ -49,10 +49,10 @@ export function usePagination(
}
return {
...config.pagination,
size: mergedSize.value, // 用户可以通过 pagination 来覆盖 size
...pagination,
pageIndex: pagination.pageIndex ?? tempIndex.value,
pageSize: pagination.pageSize ?? tempSize.value,
size: mergedSize.value,
onChange: handlePageChange,
}
})
Expand Down
Expand Up @@ -10,16 +10,16 @@ import type { ActiveSorter } from './useSortable'
import type { TablePagination, TableProps } from '../types'
import type { TableConfig } from '@idux/components/config'

import { type ComputedRef, type WatchStopHandle, computed, watch } from 'vue'
import { type ComputedRef, type Ref, type WatchStopHandle, computed, watch } from 'vue'

import { type VirtualScrollToFn } from '@idux/cdk/scroll'

export function useScrollOnChange(
props: TableProps,
config: TableConfig,
mergedPagination: ComputedRef<TablePagination | null>,
activeSorters: ComputedRef<ActiveSorter[]>,
activeFilters: ComputedRef<ActiveFilter[]>,
activeSorters: Ref<ActiveSorter[]>,
activeFilters: Ref<ActiveFilter[]>,
scrollTo: VirtualScrollToFn,
): void {
const mergedScrollToTopOnChange = computed(() => props.scrollToTopOnChange ?? config.scrollToTopOnChange)
Expand Down

0 comments on commit b647883

Please sign in to comment.