Skip to content

Commit

Permalink
fix(comp:table): pagination should render but hide when empty (#1940)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Jun 12, 2024
1 parent 502d8ce commit e2f7a65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
24 changes: 10 additions & 14 deletions packages/components/table/src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,21 @@ export default defineComponent({
const header = <ɵHeader v-slots={slots} header={props.header} />
const footer = renderFooter(slots, prefixCls)

const [paginationTop, paginationBottom] = renderPagination(
slots,
mergedPagination.value,
filteredData.value,
flattedData.value.length > 0,
prefixCls,
)
const children = [header]
let resetChildren = [<MainTable />, footer].filter(Boolean) as VNode[]

if (flattedData.value.length > 0) {
const [paginationTop, paginationBottom] = renderPagination(
slots,
mergedPagination.value,
filteredData.value,
prefixCls,
)

resetChildren = [paginationTop, ...resetChildren, paginationBottom].filter(Boolean) as VNode[]
}
const restChildren = [paginationTop, <MainTable />, footer, paginationBottom].filter(Boolean) as VNode[]

const spinProps = convertSpinProps(props.spin)
if (spinProps) {
children.push(<IxSpin {...spinProps}>{resetChildren}</IxSpin>)
children.push(<IxSpin {...spinProps}>{restChildren}</IxSpin>)
} else {
children.push(...resetChildren)
children.push(...restChildren)
}
return <div class={classes.value}>{children}</div>
}
Expand Down
3 changes: 2 additions & 1 deletion packages/components/table/src/other/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function renderPagination(
slots: Slots,
mergedPagination: TablePagination | null,
filteredData: MergedData[],
visible: boolean,
prefixCls: string,
): [VNodeChild | null, VNodeChild | null] {
let top: VNodeChild | null = null
Expand All @@ -28,7 +29,7 @@ export function renderPagination(
const className = `${prefixCls}-pagination ${prefixCls}-pagination-${horizontal}`

const node = slots.pagination?.({ total: filteredData.length, ...mergedPagination }) ?? (
<IxPagination class={className} total={filteredData.length} {...mergedPagination} />
<IxPagination v-show={visible} class={className} total={filteredData.length} {...mergedPagination} />
)

top = vertical === 'top' ? node : null
Expand Down

0 comments on commit e2f7a65

Please sign in to comment.