Skip to content

bug(aria/menu): focusFirstItem method does not exist #32741

@vprint

Description

@vprint

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

focusFirstItem is a Menu method described here https://angular.dev/guide/aria/menu. However it looks like this method is not truly implemented, as i can't access it (TS2339: Property focusFirstItem does not exist on type Menu<string)

Reproduction

<div ngMenu class="menu" #formatMenu="ngMenu">
    <ng-template ngMenuContent>
      @if (geocoderService.hasSuggestions()) {
        @for (suggestion of geocoderService.suggestions(); track suggestion) {
          <div ngMenuItem [value]="getTitle(suggestion)">
            <span class="label">{{ getTitle(suggestion) }}</span>
          </div>
        }
      }

      @if (geocoderService.suggestions().length === 0 && geocoderService.userInput().length >= 3) {
        <div ngMenu class="menu">
          <div ngMenuItem value="{{ UiText[Components.Geocoder].notFound }}">
            <span class="label">{{ UiText[Components.Geocoder].notFound }}</span>
          </div>
        </div>
      }
    </ng-template>
  </div>
export class AriaGeocoderMenu {
  protected geocoderService = inject(GeocoderService);
  protected formatMenu = viewChild<Menu<string>>('formatMenu');

  protected constructor() {
    effect(() => {
      const suggestions = this.geocoderService.suggestions()

      if (suggestions) {
        this.formatMenu()?.focusFirstItem()
        // This throw `TS2339: Property focusFirstItem does not exist on type Menu<string>`
      }
    })
  }
}

Expected Behavior

focusFirstItem implemented

Actual Behavior

focusFirstItem is not implemented while documented.

Environment

  • Aria: (Angular 21) Menu
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions