@@ -119,7 +119,7 @@ export function DPagination(props: DPaginationProps) {
119119 }
120120 ) }
121121 role = "button"
122- tabIndex = { dDisabled ? undefined : 0 }
122+ tabIndex = { 0 }
123123 title = { t ( 'Previous page' ) }
124124 aria-disabled = { active === 1 }
125125 onClick = { ( ) => {
@@ -152,7 +152,7 @@ export function DPagination(props: DPaginationProps) {
152152 [ `${ dPrefix } pagination__item--border` ] : ! ( dCustomRender && dCustomRender . next ) ,
153153 } ) }
154154 role = "button"
155- tabIndex = { dDisabled ? undefined : 0 }
155+ tabIndex = { 0 }
156156 title = { t ( 'Next page' ) }
157157 aria-disabled = { active === lastPage }
158158 onClick = { ( ) => {
@@ -180,7 +180,7 @@ export function DPagination(props: DPaginationProps) {
180180 } ,
181181 nextNode ,
182182 ] ;
183- } , [ active , changeActive , dCompose , dCustomRender , dDisabled , dPrefix , lastPage , t ] ) ;
183+ } , [ active , changeActive , dCompose , dCustomRender , dPrefix , lastPage , t ] ) ;
184184
185185 const sizeNode = useMemo ( ( ) => {
186186 const options = dPageSizeOptions . map ( ( size ) => ( {
@@ -251,6 +251,25 @@ export function DPagination(props: DPaginationProps) {
251251 return null ;
252252 } , [ changeActive , dCompose , dCustomRender , dDisabled , dMini , dPrefix , jumpValue , lastPage , t ] ) ;
253253
254+ const handleMouseDown = useCallback < React . MouseEventHandler < HTMLElement > > (
255+ ( e ) => {
256+ if ( dDisabled ) {
257+ e . preventDefault ( ) ;
258+ e . stopPropagation ( ) ;
259+ }
260+ } ,
261+ [ dDisabled ]
262+ ) ;
263+ const handleClick = useCallback < React . MouseEventHandler < HTMLElement > > (
264+ ( e ) => {
265+ if ( dDisabled ) {
266+ e . preventDefault ( ) ;
267+ e . stopPropagation ( ) ;
268+ }
269+ } ,
270+ [ dDisabled ]
271+ ) ;
272+
254273 return (
255274 < nav
256275 { ...restProps }
@@ -259,7 +278,7 @@ export function DPagination(props: DPaginationProps) {
259278 'is-disabled' : dDisabled ,
260279 'is-change' : isChange ,
261280 } ) }
262- tabIndex = { dDisabled ? undefined : - 1 }
281+ tabIndex = { - 1 }
263282 role = "navigation"
264283 aria-label = "Pagination Navigation"
265284 >
@@ -303,7 +322,7 @@ export function DPagination(props: DPaginationProps) {
303322 }
304323
305324 return (
306- < ul key = "pages" className = { `${ dPrefix } pagination__list` } >
325+ < ul key = "pages" className = { `${ dPrefix } pagination__list` } onMouseDownCapture = { handleMouseDown } onClickCapture = { handleClick } >
307326 { prevNode }
308327 { pages . map ( ( n ) => {
309328 if ( n === 'prev5' ) {
@@ -316,7 +335,7 @@ export function DPagination(props: DPaginationProps) {
316335 `${ dPrefix } pagination__item--jump5`
317336 ) }
318337 role = "button"
319- tabIndex = { dDisabled ? undefined : 0 }
338+ tabIndex = { 0 }
320339 title = { t ( '5 pages forward' ) }
321340 onClick = { ( ) => {
322341 changeActive ( Math . max ( active - 5 , 1 ) ) ;
@@ -344,7 +363,7 @@ export function DPagination(props: DPaginationProps) {
344363 `${ dPrefix } pagination__item--jump5`
345364 ) }
346365 role = "button"
347- tabIndex = { dDisabled ? undefined : 0 }
366+ tabIndex = { 0 }
348367 title = { t ( '5 pages backward' ) }
349368 onClick = { ( ) => {
350369 changeActive ( Math . min ( active + 5 , lastPage ) ) ;
@@ -374,7 +393,7 @@ export function DPagination(props: DPaginationProps) {
374393 'is-active' : active === n ,
375394 }
376395 ) }
377- tabIndex = { dDisabled ? undefined : 0 }
396+ tabIndex = { 0 }
378397 onClick = { ( ) => {
379398 changeActive ( n ) ;
380399 } }
0 commit comments