Skip to content

Commit cdd2a28

Browse files
authored
feat: add item for prev/next (#642)
* feat: add item for prev/next * add test * add test
1 parent c6cd4db commit cdd2a28

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Pagination.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,10 @@ const Pagination: React.FC<PaginationProps> = (props) => {
523523
onClick={prevHandle}
524524
tabIndex={prevDisabled ? null : 0}
525525
onKeyDown={runIfEnterPrev}
526-
className={classNames(`${prefixCls}-prev`, {
526+
className={classNames(`${prefixCls}-prev`, paginationClassNames?.item, {
527527
[`${prefixCls}-disabled`]: prevDisabled,
528528
})}
529+
style={styles?.item}
529530
aria-disabled={prevDisabled}
530531
>
531532
{prev}
@@ -551,9 +552,10 @@ const Pagination: React.FC<PaginationProps> = (props) => {
551552
onClick={nextHandle}
552553
tabIndex={nextTabIndex}
553554
onKeyDown={runIfEnterNext}
554-
className={classNames(`${prefixCls}-next`, {
555+
className={classNames(`${prefixCls}-next`, paginationClassNames?.item, {
555556
[`${prefixCls}-disabled`]: nextDisabled,
556557
})}
558+
style={styles?.item}
557559
aria-disabled={nextDisabled}
558560
>
559561
{next}

tests/index.test.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,26 @@ describe('Other props', () => {
251251
/>,
252252
);
253253
const item = container.querySelector('.rc-pagination-item');
254+
const prev = container.querySelector('.rc-pagination-prev');
255+
const next = container.querySelector('.rc-pagination-next');
254256
expect(item).toHaveClass('custom-test');
257+
expect(prev).toHaveClass('custom-test');
258+
expect(next).toHaveClass('custom-test');
255259
expect(item).toHaveStyle('color: red');
260+
expect(prev).toHaveStyle('color: red');
261+
expect(next).toHaveStyle('color: red');
262+
});
263+
it('should have 5 items when there are 3 pages and current page is 2', () => {
264+
const { container } = render(
265+
<Pagination
266+
total={15}
267+
pageSize={5}
268+
current={2}
269+
classNames={{ item: 'custom-test' }}
270+
/>,
271+
);
272+
const items = container.querySelectorAll('.custom-test');
273+
expect(items.length).toBe(5);
256274
});
257275
it('should support custom default icon', () => {
258276
const nextIcon = () => <span>nextIcon</span>;

0 commit comments

Comments
 (0)