angular / angular/components

feat(CdkMenu): Option to disable typeahead in CdkMenu

Abierto
#30,384 1 comentario 0 reacciones 0 asignados Ver en GitHub
area: cdk/menu feature P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

### Feature Description

We would like to add an option in the `CdkMenu` to disable the integrated TypeAhead feature.

Currently, the menu activates the TypeAhead for its `FocusKeyManager` automatically:
https://github.com/angular/components/blob/e91d5091bbf3d44cc168be458269d260a0c22c27/src/cdk/menu/menu-base.ts#L175

The proposal would be to add an input like `cdkMenuTypeAhead: boolean` which defaults to true but can be used to skip the TypeAhead activation:
```ts
this.keyManager = new FocusKeyManager(this.items).withWrap().withHomeAndEnd();
if (this.cdkMenuTypeAhead) {
this.keyManager = this.keyManager.withTypeAhead()
}
```

#### Alternative

An alternative approach might be a combination of the following features, so the described use case can be accomplished by the `CdkMenu` itself.
1. Make the current search term (`_pressedLetters`) publicly available, so it can be displayed.
2. Two variants to extend the current search logic:
2.a Add a secondary `includes` search to the current `startsWith`.
2.b Make the search logic customizable with configurable predicate function.

### Use Case

The use case is a custom search feature for our menus, which conflicts with the integrated TypeAhead.
We want to display the current search term and search by `startsWith` & `includes`.

![Image](https://github.com/user-attachments/assets/9a9823aa-e645-4c02-98c8-71e8361e8178) ![Image](https://github.com/user-attachments/assets/be067fd8-0133-498d-a702-b3534632be16)

***

**🗨 I would appreciate some feedback, if this feature has a chance of being accepted. Then I can prepare a PR for this.**

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en src/cdk/menu/menu-base.ts, en la configuración de FocusKeyManager alrededor de la línea enlazada, y luego sigue cómo se declaran las entradas de CdkMenu y cómo se activa typeahead. El cambio estará completo cuando el menú pueda excluirse de typeahead conservando el comportamiento predeterminado actual; revisa las pruebas existentes del menú, si están disponibles, para verificar ambas rutas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.