@@ -6,6 +6,7 @@ import { DoubleLeftOutlined, DoubleRightOutlined, EllipsisOutlined, LeftOutlined
66import { registerComponentMate , getClassName } from '../../utils' ;
77import { DInput } from '../input' ;
88import { DSelect } from '../select' ;
9+ import { getButtonRoleAttributes } from './utils' ;
910
1011export interface DPaginationProps extends Omit < React . HTMLAttributes < HTMLElement > , 'children' > {
1112 dActive ?: number ;
@@ -98,6 +99,9 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
9899 if ( dCompose . includes ( 'pages' ) ) {
99100 prevNode = (
100101 < li
102+ { ...getButtonRoleAttributes ( ( ) => {
103+ changeActive ( active - 1 ) ;
104+ } , active === 1 ) }
101105 className = { getClassName (
102106 `${ dPrefix } pagination__item` ,
103107 `${ dPrefix } pagination__item--button` ,
@@ -108,28 +112,21 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
108112 }
109113 ) }
110114 title = { t ( 'Pagination' , 'Previous page' ) }
111- role = "button"
112- aria-disabled = { active === 1 }
113- onClick = { ( ) => {
114- changeActive ( active - 1 ) ;
115- } }
116115 >
117116 { dCustomRender && dCustomRender . prev ? dCustomRender . prev : < LeftOutlined /> }
118117 </ li >
119118 ) ;
120119
121120 nextNode = (
122121 < li
122+ { ...getButtonRoleAttributes ( ( ) => {
123+ changeActive ( active + 1 ) ;
124+ } , active === lastPage ) }
123125 className = { getClassName ( `${ dPrefix } pagination__item` , `${ dPrefix } pagination__item--button` , {
124126 'is-disabled' : active === lastPage ,
125127 [ `${ dPrefix } pagination__item--border` ] : ! ( dCustomRender && dCustomRender . next ) ,
126128 } ) }
127129 title = { t ( 'Pagination' , 'Next page' ) }
128- role = "button"
129- aria-disabled = { active === lastPage }
130- onClick = { ( ) => {
131- changeActive ( active + 1 ) ;
132- } }
133130 >
134131 { dCustomRender && dCustomRender . next ? dCustomRender . next : < RightOutlined /> }
135132 </ li >
@@ -271,17 +268,16 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
271268 if ( n === 'prev5' ) {
272269 return (
273270 < li
271+ { ...getButtonRoleAttributes ( ( ) => {
272+ changeActive ( active - 5 ) ;
273+ } ) }
274274 key = "prev5"
275275 className = { getClassName (
276276 `${ dPrefix } pagination__item` ,
277277 `${ dPrefix } pagination__item--button` ,
278278 `${ dPrefix } pagination__item--jump5`
279279 ) }
280280 title = { t ( 'Pagination' , '5 pages forward' ) }
281- role = "button"
282- onClick = { ( ) => {
283- changeActive ( active - 5 ) ;
284- } }
285281 >
286282 < DoubleLeftOutlined className = { `${ dPrefix } pagination__jump5-icon` } />
287283 < div className = { `${ dPrefix } pagination__ellipsis` } >
@@ -292,17 +288,16 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
292288 } else if ( n === 'next5' ) {
293289 return (
294290 < li
291+ { ...getButtonRoleAttributes ( ( ) => {
292+ changeActive ( active + 5 ) ;
293+ } ) }
295294 key = "next5"
296295 className = { getClassName (
297296 `${ dPrefix } pagination__item` ,
298297 `${ dPrefix } pagination__item--button` ,
299298 `${ dPrefix } pagination__item--jump5`
300299 ) }
301300 title = { t ( 'Pagination' , '5 pages backward' ) }
302- role = "button"
303- onClick = { ( ) => {
304- changeActive ( active + 5 ) ;
305- } }
306301 >
307302 < DoubleRightOutlined className = { `${ dPrefix } pagination__jump5-icon` } />
308303 < div className = { `${ dPrefix } pagination__ellipsis` } >
0 commit comments