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
Add autoHide to Pagination #8615
Add autoHide to Pagination #8615
Conversation
78564f0
to
992ebb1
Compare
Hmm, how about moving this prop to |
@yesmeck sure, will do |
@@ -37,6 +37,21 @@ describe('Table.pagination', () => { | |||
expect(wrapper).toMatchSnapshot(); | |||
}); | |||
|
|||
it.only('should have pager when change pagination from false to undefined', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "only".
And, you should PR to master. |
Codecov Report
@@ Coverage Diff @@
## master #8615 +/- ##
========================================
Coverage ? 85%
========================================
Files ? 227
Lines ? 4676
Branches ? 1369
========================================
Hits ? 3975
Misses ? 701
Partials ? 0
Continue to review full report at Codecov.
|
@yesmeck I'm still using 2.x, I will make a PR to master as well. |
You still need to PR to master, If we need release 2.x, we will cherry pick this feature to |
ddfdd3f
to
930bdf4
Compare
components/pagination/Pagination.tsx
Outdated
@@ -50,6 +51,10 @@ export default class Pagination extends React.Component<PaginationProps, {}> { | |||
} | |||
|
|||
render() { | |||
// When autoHide is true and there is only 1 page, hide the pager | |||
if (this.props.autoHide === true && (this.props.total || 0) <= (this.props.pageSize || 10)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaultPageSize
comes from rc-pagination
, I think rc-paginaion
is a better place a add this feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, done
|
930bdf4
to
92bd9de
Compare
@camsong rc-pagination published, you need to upgrade it to ~1.13.0 in antd. |
92bd9de
to
50435c7
Compare
@yutingzhao1991 Thanks so much. It seems antd also need to be published to get TypeScript support |
接口先自己覆盖下吧 /// <reference types="react" />
import * as React from 'react';
declare module 'antd/lib/pagination/Pagination' {
interface PaginationProps {
hideOnSinglePage?: boolean;
}
} |
b59610b
to
57d0a60
Compare
@yesmeck target branch changed, your patch works for now. |
Should update |
57d0a60
to
25a0210
Compare
It's quite cumbersome to show pagination when there is only 1 page.
Code like this can help but you need to define a const
pageSize
and not elegant.This is a common requirement so better to have a prop specifically for it.
autoHidePagination
default isfalse
, so it will not break any current behavior.May refer to #4173