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

[Autocomplete] Custom Popper with "Action Option" keyboard support #45224

Open
mogrady88 opened this issue Feb 5, 2025 · 1 comment
Open
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for author Issue with insufficient information

Comments

@mogrady88
Copy link
Contributor

mogrady88 commented Feb 5, 2025

Hey,

I'm trying to implement an Autocomplete with a custom Popper and an "action Item" at the top of the list. The "action item" is a ListItemButton. This renders just fine, which is great, but I'm running into issues trying to add keyboard support to this implementation. The user should be able to Tab to the "action item" in order to interact with it but when I press Tab the Autocomplete closes.

I have not found any way to keep the menu open when I press the Tab key. Do you have any ideas on how I could achieve this?

Implementation:
Image

Popper Code:
Image

onKeyDown Handler Code (handleBaseKeyDown is mapped to the onKeyDown prop on Autocomplete):
Image

Search keywords:

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 5, 2025
@mj12albert
Copy link
Member

mj12albert commented Feb 6, 2025

onKeyDown Handler Code (handleBaseKeyDown is mapped to the onKeyDown prop on Autocomplete)

@mogrady88 Instead of preventDefault(), does this work:

event.defaultMuiPrevented = true;

Reference: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/useAutocomplete/useAutocomplete.js#L760-L767

@mj12albert mj12albert added package: material-ui Specific to @mui/material component: autocomplete This is the name of the generic UI component, not the React module! labels Feb 6, 2025
@mj12albert mj12albert changed the title MUI Autocomplete Custom Popper with "Action Option" keyboard support [Autocomplete] Custom Popper with "Action Option" keyboard support Feb 6, 2025
@mj12albert mj12albert added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

2 participants