Skip to content

Commit

Permalink
fix(material/paginator): refactoring
Browse files Browse the repository at this point in the history
refactoring code to make cleaner

Fixes b/286098030
  • Loading branch information
DBowen33 committed May 6, 2024
1 parent 6b03de0 commit 6ff975b
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/material/paginator/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ export class MatPaginator implements OnInit, OnDestroy {
/** ID for the DOM node containing the paginator's items per page label. */
readonly _pageSizeLabelId = `mat-paginator-page-size-label-${nextUniqueId++}`;

/** MDC class names of paginator buttons. */
readonly _pageNext = 'mat-mdc-paginator-navigation-next';
readonly _pagePrevious = 'mat-mdc-paginator-navigation-previous';
readonly _pageFirst = 'mat-mdc-paginator-navigation-first';
readonly _pageLast = 'mat-mdc-paginator-navigation-last';

private _intlChanges: Subscription;
private _isInitialized = false;
private _initializedStream = new ReplaySubject<void>(1);
Expand Down Expand Up @@ -311,29 +317,20 @@ export class MatPaginator implements OnInit, OnDestroy {

setTimeout(() => {
event.preventDefault();
if (
currentElement.disabled &&
currentElement.classList.contains('mat-mdc-paginator-navigation-next')
) {
if (currentElement.disabled && currentElement.classList.contains(this._pageNext)) {
const previousElement = currentElement.previousElementSibling as HTMLButtonElement;
previousElement?.focus();
} else if (
currentElement.disabled &&
currentElement.classList.contains('mat-mdc-paginator-navigation-previous')
currentElement.classList.contains(this._pagePrevious)
) {
const nextElement = currentElement.nextElementSibling as HTMLButtonElement;
nextElement?.focus();
} else if (
currentElement.disabled &&
currentElement.classList.contains('mat-mdc-paginator-navigation-first')
) {
} else if (currentElement.disabled && currentElement.classList.contains(this._pageFirst)) {
const nextElement = currentElement.nextElementSibling
?.nextElementSibling as HTMLButtonElement;
nextElement?.focus();
} else if (
currentElement.disabled &&
currentElement.classList.contains('mat-mdc-paginator-navigation-last')
) {
} else if (currentElement.disabled && currentElement.classList.contains(this._pageLast)) {
const previousElement = currentElement.previousElementSibling
?.previousElementSibling as HTMLButtonElement;
previousElement?.focus();
Expand Down

0 comments on commit 6ff975b

Please sign in to comment.