angular/components · error

Could not find last page button inside paginator. Make sure

Error message

Could not find last page button inside paginator. Make sure that `showFirstLastButtons` is enabled.

What it means

MatPaginatorHarness `goToLastPage()` throws because the last-page button is not rendered unless `showFirstLastButtons` is enabled. The harness queries `_lastPageButton()` and throws when it is absent.

Source

Thrown at src/material/paginator/testing/paginator-harness.ts:89

    // The first page button isn't enabled by default so we need to check for it.
    if (!button) {
      throw Error(
        'Could not find first page button inside paginator. ' +
          'Make sure that `showFirstLastButtons` is enabled.',
      );
    }

    return button.click();
  }

  /** Goes to the last page in the paginator. */
  async goToLastPage(): Promise<void> {
    const button = await this._lastPageButton();

    // The last page button isn't enabled by default so we need to check for it.
    if (!button) {
      throw Error(
        'Could not find last page button inside paginator. ' +
          'Make sure that `showFirstLastButtons` is enabled.',
      );
    }

    return button.click();
  }

  /**
   * Sets the page size of the paginator.
   * @param size Page size that should be select.
   */
  async setPageSize(size: number): Promise<void> {
    const select = await this._select();

    // The select is only available if the `pageSizeOptions` are
    // set to an array with more than one item.
    if (!select) {

View on GitHub (pinned to 0411926e7d)

Solutions

  1. Set `[showFirstLastButtons]="true"` on the paginator
  2. Navigate with `goToPage(lastIndex)` or `nextPage()` when the flag is intentionally off
  3. Check template changes that may have dropped the binding

Example fix

// before
<mat-paginator [length]="100"></mat-paginator>
// after
<mat-paginator [length]="100" [showFirstLastButtons]="true"></mat-paginator>
Defensive patterns

Strategy: validation

Validate before calling

// ensure template enables the buttons before calling:
// <mat-paginator [showFirstLastButtons]="true">

Try / catch

try {
  await paginatorHarness.goToLastPage();
} catch (e) {
  if (String(e?.message).includes('last page button')) {
    fail('Enable showFirstLastButtons on the paginator under test');
  }
  throw e;
}

Prevention

When it happens

Trigger: `await paginatorHarness.goToLastPage()` on a paginator whose `showFirstLastButtons` input is false/omitted.

Common situations: Default paginator setup without the input; template regression removing the flag; copied test harness usage from a project that enables the flag.

Related errors


AI-assisted analysis of angular/components@0411926e7d (2026-08-31). Data as JSON: /api/errors/8a126223653af339. Report an issue: GitHub.