[material-ui][Select] Allow specifying which keydowns open the menu #40501
Labels
component: select
This is the name of the generic UI component, not the React module!
enhancement
This is not a bug, nor a new feature
package: material-ui
Specific to @mui/material
waiting for 👍
Waiting for upvotes
Duplicates
Summary
It would be nice if developers could specify which keydowns open the menu without having to take ownership of what
SelectInput
otherwise manages internally when its open state is uncontrolled in order to do so.Examples
No response
Motivation
We are using
Select
s as filter fields on a typical index screen, and we have already trained our users on using aCMD/CTRL + Enter
keyboard shortcut to submit the current set of filter values to perform a search.When that keyboard shortcut is issued and a
Select
has focus and/or is the active element, however, its menu will be opened.It is great that pressing
Enter
when aSelect
has focus and/or is the active element does open its menu, but in theCMD/CTRL + Enter
case, it would be a preferable UX to have it remained closed.It is worth mentioning that
Autocomplete
does not open its menu whenCMD/CTRL + Enter
is pressed when it has focus and/or is the active element.On a more general note, there seemed to be several old, closed issues that discussed event propagation and/or the ability to compose default behavior of event handling into custom event handlers, but all of those seemed to be in the context of
Autocomplete
:Perhaps related was mui/mui-x#1403 specific to
DataGrid
that introduced thedefaultMuiPrevented
on events which I'm assuming eventually led to being able to disable the default behavior The motivations there may not be identical here, but it did seem to deal with allowing developers to override the default event handling in cases without having to completely opt out of it and write it themselves if there were still cases where they wanted the default event handling behavior.I most certainly do not have the context that y'all have to make the best informed decision about how to best add something like this to the API, so take this suggestion purely as another way to explain what I'd like to be able to do. It seems like
material-ui/packages/mui-material/src/Select/SelectInput.js
Lines 309 to 325 in 0d93e4a
could start by accepting some prop that allowed developers to specify which keydown event conditions should open the menu without having to provide the
onKeyDown
prop such that the logic inSelectInput
's internalhandleKeyDown
could still be called. I'm imagining something like the following being evaluated that would take the place of thevalidKeys
inclusion check withinhandleKeyDown
in the snippet aboveThank you for your consideration and your work on this project.
Search keywords:
The text was updated successfully, but these errors were encountered: