@@ -124,6 +124,16 @@ class CDSPagination extends FocusMixin(HostListenerMixin(LitElement)) {
124124 if ( newStart !== oldStart ) {
125125 this . _handleUserInitiatedChangeStart ( newStart ) ;
126126 }
127+ // reset focus to forward button if it reaches the beginning
128+ if ( this . page === 1 ) {
129+ const { selectorForwardButton } = this
130+ . constructor as typeof CDSPagination ;
131+ (
132+ this . shadowRoot ?. querySelector (
133+ `[button-class-name*=${ selectorForwardButton } ]`
134+ ) as HTMLElement
135+ ) . focus ( ) ;
136+ }
127137 }
128138
129139 /**
@@ -136,6 +146,16 @@ class CDSPagination extends FocusMixin(HostListenerMixin(LitElement)) {
136146 if ( newStart < ( totalItems == null ? Infinity : totalItems ) ) {
137147 this . _handleUserInitiatedChangeStart ( newStart ) ;
138148 }
149+ // reset focus to previous button if it reaches the end
150+ if ( this . page === this . totalPages ) {
151+ const { selectorPreviousButton } = this
152+ . constructor as typeof CDSPagination ;
153+ (
154+ this . shadowRoot ?. querySelector (
155+ `[button-class-name*=${ selectorPreviousButton } ]`
156+ ) as HTMLElement
157+ ) . focus ( ) ;
158+ }
139159 }
140160
141161 /**
@@ -470,6 +490,20 @@ class CDSPagination extends FocusMixin(HostListenerMixin(LitElement)) {
470490 return `${ prefix } -select` ;
471491 }
472492
493+ /**
494+ * A selector that will return the previous button.
495+ */
496+ static get selectorPreviousButton ( ) {
497+ return `${ prefix } --pagination__button--backward` ;
498+ }
499+
500+ /**
501+ * A selector that will return the forward button.
502+ */
503+ static get selectorForwardButton ( ) {
504+ return `${ prefix } --pagination__button--forward` ;
505+ }
506+
473507 /**
474508 * The name of the custom event fired after the current row number is changed.
475509 */
0 commit comments