Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CdkMenu): Option to disable typeahead in CdkMenu #30384

Open
twittwer opened this issue Jan 24, 2025 · 1 comment
Open

feat(CdkMenu): Option to disable typeahead in CdkMenu #30384

twittwer opened this issue Jan 24, 2025 · 1 comment
Labels
area: cdk/menu feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@twittwer
Copy link
Contributor

twittwer commented Jan 24, 2025

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:

this.keyManager = new FocusKeyManager(this.items).withWrap().withTypeAhead().withHomeAndEnd();

The proposal would be to add an input like cdkMenuTypeAhead: boolean which defaults to true but can be used to skip the TypeAhead activation:

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 Image


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

@twittwer twittwer added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Jan 24, 2025
@wagnermaciel wagnermaciel added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/menu and removed needs triage This issue needs to be triaged by the team labels Jan 29, 2025
@wagnermaciel
Copy link
Contributor

wagnermaciel commented Jan 29, 2025

A not great but easy workaround would be to define a typeaheadLabel that's some non-typeable character

<button cdkMenuitemTypeaheadLabel="👍" cdkMenuItem>Inbox</button>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/menu feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

2 participants