@@ -11,6 +11,7 @@ import zhCN from './locale/zh_CN';
1111import Options from './Options' ;
1212import type { PagerProps } from './Pager' ;
1313import Pager from './Pager' ;
14+ import getNonEmptyString from './utils/getNonEmptyString' ;
1415
1516const defaultItemRender : PaginationProps [ 'itemRender' ] = ( _ , __ , element ) =>
1617 element ;
@@ -32,10 +33,6 @@ function calculatePage(p: number | undefined, pageSize: number, total: number) {
3233 return Math . floor ( ( total - 1 ) / _pageSize ) + 1 ;
3334}
3435
35- function getNonEmptyString ( ...values : ( string | undefined ) [ ] ) {
36- return values . find ( ( value ) => value && value . trim ( ) ) ?. trim ( ) ;
37- }
38-
3936const Pagination : React . FC < PaginationProps > = ( props ) => {
4037 const {
4138 // cls
@@ -120,13 +117,14 @@ const Pagination: React.FC<PaginationProps> = (props) => {
120117
121118 function getItemIcon (
122119 icon : React . ReactNode | React . ComponentType < PaginationProps > ,
123- label : string ,
120+ _label : string ,
124121 title ?: string ,
125122 ) {
126123 let iconNode = icon || (
127124 < button
128125 type = "button"
129- aria-label = { label }
126+ tabIndex = { - 1 }
127+ aria-hidden = "true"
130128 title = { title }
131129 className = { `${ prefixCls } -item-link` }
132130 />
@@ -159,7 +157,6 @@ const Pagination: React.FC<PaginationProps> = (props) => {
159157
160158 const shouldDisplayQuickJumper = total > pageSize ? showQuickJumper : false ;
161159 const pageLabelText = getNonEmptyString ( locale . page , 'Page' ) ;
162- const pageSizeLabelText = getNonEmptyString ( locale . page_size , 'Page Size' ) ;
163160
164161 /**
165162 * prevent "up arrow" key reseting cursor position within textbox
@@ -254,7 +251,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
254251 handleChange ( jumpNextPage ) ;
255252 }
256253
257- function runIfEnter (
254+ function runIfEnterOrSpace (
258255 event : React . KeyboardEvent < HTMLLIElement > ,
259256 callback : ( ...args : any [ ] ) => void ,
260257 ...restParams : any [ ]
@@ -272,19 +269,19 @@ const Pagination: React.FC<PaginationProps> = (props) => {
272269 }
273270
274271 function runIfEnterPrev ( event : React . KeyboardEvent < HTMLLIElement > ) {
275- runIfEnter ( event , prevHandle ) ;
272+ runIfEnterOrSpace ( event , prevHandle ) ;
276273 }
277274
278275 function runIfEnterNext ( event : React . KeyboardEvent < HTMLLIElement > ) {
279- runIfEnter ( event , nextHandle ) ;
276+ runIfEnterOrSpace ( event , nextHandle ) ;
280277 }
281278
282279 function runIfEnterJumpPrev ( event : React . KeyboardEvent < HTMLLIElement > ) {
283- runIfEnter ( event , jumpPrevHandle ) ;
280+ runIfEnterOrSpace ( event , jumpPrevHandle ) ;
284281 }
285282
286283 function runIfEnterJumpNext ( event : React . KeyboardEvent < HTMLLIElement > ) {
287- runIfEnter ( event , jumpNextHandle ) ;
284+ runIfEnterOrSpace ( event , jumpNextHandle ) ;
288285 }
289286
290287 function renderPrev ( prevPage : number ) {
@@ -354,7 +351,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
354351 const pagerProps : PagerProps = {
355352 rootPrefixCls : prefixCls ,
356353 onClick : handleChange ,
357- onKeyPress : runIfEnter ,
354+ onKeyPress : runIfEnterOrSpace ,
358355 showTitle,
359356 itemRender,
360357 pageLabel : pageLabelText ,
@@ -628,11 +625,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
628625 { simple ? simplePager : pagerList }
629626 { next }
630627 < Options
631- locale = { {
632- ...locale ,
633- page_size : pageSizeLabelText ,
634- page : getNonEmptyString ( locale . page , pageLabelText , 'Page' ) ,
635- } }
628+ locale = { locale }
636629 rootPrefixCls = { prefixCls }
637630 disabled = { disabled }
638631 selectPrefixCls = { selectPrefixCls }
0 commit comments