Skip to content

Commit

Permalink
fix(comp: pagination): Showquickjumper does not work in simple mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzaijiang committed May 25, 2022
1 parent ae8fdef commit 2955e7f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`Pagination > render work 2`] = `
"<ul class=\\"ix-pagination ix-pagination-simple ix-pagination-md\\">
<li class=\\"ix-pagination-total\\">共 50 项</li>
<li class=\\"ix-pagination-item ix-pagination-item-button\\" title=\\"上一页\\"><button class=\\"ix-button ix-button-disabled ix-button-icon-only ix-button-text ix-button-circle ix-button-sm\\" disabled=\\"\\" type=\\"button\\"><i class=\\"ix-icon ix-icon-left\\" role=\\"img\\" aria-label=\\"left\\"></i></button></li>
<li class=\\"ix-pagination-item\\"><input class=\\"ix-input ix-input-md\\"><span class=\\"ix-pagination-item-slash\\">/</span><span>5</span></li>
<li class=\\"ix-pagination-item\\">1<span class=\\"ix-pagination-item-slash\\">/</span><span>5</span></li>
<li class=\\"ix-pagination-item ix-pagination-item-button\\" title=\\"下一页\\"><button class=\\"ix-button ix-button-icon-only ix-button-text ix-button-circle ix-button-sm\\" type=\\"button\\"><i class=\\"ix-icon ix-icon-right\\" role=\\"img\\" aria-label=\\"right\\"></i></button></li>
</ul>"
`;
Expand Down
8 changes: 7 additions & 1 deletion packages/components/pagination/__tests__/pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ describe('Pagination', () => {

test('simple work', async () => {
const onUpdatePageIndex = vi.fn()
const wrapper = PaginationMount({ props: { total: 50, simple: true, 'onUpdate:pageIndex': onUpdatePageIndex } })
const wrapper = PaginationMount({
props: { total: 50, simple: true, showQuickJumper: true, 'onUpdate:pageIndex': onUpdatePageIndex },
})

expect(wrapper.find('.ix-pagination-item-slash').exists()).toBeTruthy()

Expand All @@ -149,6 +151,10 @@ describe('Pagination', () => {
await next.trigger('click')

expect(onUpdatePageIndex).toBeCalledWith(5)

await wrapper.setProps({ showQuickJumper: false })

expect(wrapper.find('.ix-input').exists()).toBeFalsy()
})

test('size work', async () => {
Expand Down
8 changes: 5 additions & 3 deletions packages/components/pagination/demo/Simple.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<IxPagination :total="500" simple />
<br />
<IxPagination :total="500" simple disabled />
<IxSpace vertical block>
<IxPagination :total="500" simple />
<IxPagination :total="500" simple showQuickJumper />
<IxPagination :total="500" simple disabled />
</IxSpace>
</template>
16 changes: 10 additions & 6 deletions packages/components/pagination/src/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ export default defineComponent({
children.push(<Item disabled={_activeIndex === 1} type="prev" />)
children.push(
<li class={`${prefixCls}-item`}>
<ɵInput
disabled={props.disabled}
size={size.value}
value={_activeIndex.toString()}
onKeydown={jumpToIndex}
/>
{showQuickJumper.value ? (
<ɵInput
disabled={props.disabled}
size={size.value}
value={_activeIndex.toString()}
onKeydown={jumpToIndex}
/>
) : (
_activeIndex
)}
<span class={`${prefixCls}-item-slash`}>/</span>
<span>{_lastIndex}</span>
</li>,
Expand Down

0 comments on commit 2955e7f

Please sign in to comment.