File tree Expand file tree Collapse file tree 4 files changed +28
-20
lines changed Expand file tree Collapse file tree 4 files changed +28
-20
lines changed Original file line number Diff line number Diff line change @@ -465,9 +465,9 @@ recommended unless the content of the button textually conveys it's purpose.
465465pattern.
466466
467467- Tabbing into the pagination component will autofocus the current active page button
468- - <kbd >LEFT</kbd > and <kbd >RIGHT</kbd > arrow keys will focus the previous and next buttons in the
469- page list, respectively, and < kbd >ENTER</ kbd > or < kbd >SPACE</ kbd > keys will select (click) the
470- focused page button
468+ - <kbd >LEFT</kbd > (or < kbd >UP</ kbd >) and <kbd >RIGHT</kbd > (or < kbd >DOWN</ kbd >) arrow keys will focus
469+ the previous and next buttons, respectively, in the page list
470+ - < kbd >ENTER</ kbd > or < kbd >SPACE</ kbd > keys will select (click) the currently focused page button
471471- Pressing <kbd >TAB</kbd > will move to the next control or link on the page, while pressing
472472 <kbd >SHIFT</kbd >+<kbd >TAB</kbd > will move to the previous control or link on the page.
473473
Original file line number Diff line number Diff line change @@ -347,9 +347,9 @@ recommended unless the content of the button textually conveys it's purpose.
347347pattern.
348348
349349- Tabbing into the pagination component will autofocus the current active page button
350- - <kbd >LEFT</kbd > and <kbd >RIGHT</kbd > arrow keys will focus the previous and next buttons in the
351- page list, respectively, and < kbd >ENTER</ kbd > or < kbd >SPACE</ kbd > keys will select (click) the
352- focused page button
350+ - <kbd >LEFT</kbd > (or < kbd >UP</ kbd >) and <kbd >RIGHT</kbd > (or < kbd >DOWN</ kbd >) arrow keys will focus
351+ the previous and next buttons, respectively, in the page list
352+ - < kbd >ENTER</ kbd > or < kbd >SPACE</ kbd > keys will select (click) the currently focused page button
353353- Pressing <kbd >TAB</kbd > will move to the next control or link on the page, while pressing
354354 <kbd >SHIFT</kbd >+<kbd >TAB</kbd > will move to the previous control or link on the page.
355355
Original file line number Diff line number Diff line change @@ -864,7 +864,6 @@ describe('pagination', () => {
864864 expect ( document . activeElement ) . toEqual ( links . at ( 3 ) . element )
865865
866866 // LEFT
867- // links.at(3).trigger('keydown.left')
868867 wrapper . trigger ( 'keydown.left' )
869868 await waitNT ( wrapper . vm )
870869 expect ( document . activeElement ) . toEqual ( links . at ( 2 ) . element )
@@ -874,6 +873,16 @@ describe('pagination', () => {
874873 await waitNT ( wrapper . vm )
875874 expect ( document . activeElement ) . toEqual ( links . at ( 3 ) . element )
876875
876+ // UP (same as LEFT)
877+ wrapper . trigger ( 'keydown.up' )
878+ await waitNT ( wrapper . vm )
879+ expect ( document . activeElement ) . toEqual ( links . at ( 2 ) . element )
880+
881+ // DOWN (same as RIGHT)
882+ links . at ( 2 ) . trigger ( 'keydown.down' )
883+ await waitNT ( wrapper . vm )
884+ expect ( document . activeElement ) . toEqual ( links . at ( 3 ) . element )
885+
877886 // SHIFT-RIGHT
878887 links . at ( 2 ) . trigger ( 'keydown.right' , { shiftKey : true } )
879888 await waitNT ( wrapper . vm )
Original file line number Diff line number Diff line change @@ -287,6 +287,17 @@ export default {
287287 } )
288288 } ,
289289 methods : {
290+ handleKeyNav ( evt ) {
291+ const keyCode = evt . keyCode
292+ const shift = evt . shiftKey
293+ if ( keyCode === KeyCodes . LEFT || keyCode === KeyCodes . UP ) {
294+ evt . preventDefault ( )
295+ shift ? this . focusFirst ( ) : this . focusPrev ( )
296+ } else if ( keyCode === KeyCodes . RIGHT || keyCode === KeyCodes . DOWN ) {
297+ evt . preventDefault ( )
298+ shift ? this . focusLast ( ) : this . focusNext ( )
299+ }
300+ } ,
290301 getButtons ( ) {
291302 // Return only buttons that are visible
292303 return selectAll ( 'a.page-link' , this . $el ) . filter ( btn => isVisible ( btn ) )
@@ -545,19 +556,7 @@ export default {
545556 'aria-disabled' : disabled ? 'true' : 'false' ,
546557 'aria-label' : this . ariaLabel || null
547558 } ,
548- on : {
549- keydown : evt => {
550- const keyCode = evt . keyCode
551- const shift = evt . shiftKey
552- if ( keyCode === KeyCodes . LEFT ) {
553- evt . preventDefault ( )
554- shift ? this . focusFirst ( ) : this . focusPrev ( )
555- } else if ( keyCode === KeyCodes . RIGHT ) {
556- evt . preventDefault ( )
557- shift ? this . focusLast ( ) : this . focusNext ( )
558- }
559- }
560- }
559+ on : { keydown : this . handleKeyNav }
561560 } ,
562561 buttons
563562 )
You can’t perform that action at this time.
0 commit comments