Skip to content

Commit c728e86

Browse files
committed
fix: Pagination sizeOptions search handeled by showSizeOptionsSearch prop
1 parent b89cb0e commit c728e86

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ ReactDOM.render(<Pagination />, container);
6565
| totalBoundaryShowSizeChanger | when total larger than it, `showSizeChanger` will be true | number | 50 |
6666
| pageSizeOptions | specify the sizeChanger selections | Array<String> | ['10', '20', '50', '100'] |
6767
| onShowSizeChange | pageSize change callback | Function(current, size) | - |
68+
| showSizeOptionsSearch | when true can search in sizeChanger select | Bool | false |
6869
| hideOnSinglePage | hide on single page | Bool | false |
6970
| showPrevNextJumpers | show jump-prev, jump-next | Bool | true |
7071
| showQuickJumper | show quick goto jumper | Bool / Object | false / {goButton: true} |

docs/examples/sizer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class App extends React.Component {
2424
showSizeChanger
2525
pageSize={pageSize}
2626
onShowSizeChange={this.onShowSizeChange}
27+
showSizeOptionsSearch={true}
2728
defaultCurrent={3}
2829
total={40}
2930
/>

src/Options.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface OptionsProps {
1818
selectPrefixCls?: string;
1919
pageSize: number;
2020
pageSizeOptions?: (string | number)[];
21+
showSearch?: boolean;
2122
goButton?: boolean | string;
2223
changeSize?: (size: number) => void;
2324
quickGo?: (value: number) => void;
@@ -39,6 +40,7 @@ const Options: React.FC<OptionsProps> = (props) => {
3940
quickGo,
4041
rootPrefixCls,
4142
selectComponentClass: Select,
43+
showSearch,
4244
selectPrefixCls,
4345
disabled,
4446
buildOptionText,
@@ -128,7 +130,7 @@ const Options: React.FC<OptionsProps> = (props) => {
128130
<Select
129131
disabled={disabled}
130132
prefixCls={selectPrefixCls}
131-
showSearch={false}
133+
showSearch={showSearch}
132134
className={`${prefixCls}-size-changer`}
133135
optionLabelProp="children"
134136
popupMatchSelectWidth={false}

src/Pagination.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
5656
showLessItems,
5757
showTitle = true,
5858
onShowSizeChange = noop,
59+
showSizeOptionsSearch,
5960
locale = zhCN,
6061
style,
6162
totalBoundaryShowSizeChanger = 50,
@@ -576,6 +577,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
576577
rootPrefixCls={prefixCls}
577578
disabled={disabled}
578579
selectComponentClass={selectComponentClass}
580+
showSearch={showSizeOptionsSearch}
579581
selectPrefixCls={selectPrefixCls}
580582
changeSize={showSizeChanger ? changePageSize : null}
581583
pageSize={pageSize}

src/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface PaginationData {
3232

3333
hideOnSinglePage: boolean;
3434
showSizeChanger: boolean;
35+
showSizeOptionsSearch?: boolean;
3536
showLessItems: boolean;
3637
showPrevNextJumpers: boolean;
3738
showQuickJumper: boolean | object;

tests/sizer.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ describe('Pagination with sizer', () => {
6868
expect(onChange).toHaveBeenLastCalledWith(1, 10);
6969
});
7070

71+
it('should has search ability in pageSizeOptions select', () => {
72+
const { container } = render(
73+
<Pagination
74+
total={500}
75+
pageSize={15}
76+
showSizeChanger
77+
showSizeOptionsSearch
78+
selectComponentClass={Select}
79+
/>,
80+
);
81+
expect(container.querySelectorAll('.rc-select-show-search')).toHaveLength(
82+
1,
83+
);
84+
});
85+
7186
// https://github.com/ant-design/ant-design/issues/26580
7287
it('should contains locale text in selected pageSize when pageSizeOptions are numbers', () => {
7388
const { container } = render(

0 commit comments

Comments
 (0)