[DropDownMenu][SelectField] Add Keyboard support#4966
[DropDownMenu][SelectField] Add Keyboard support#4966caesay wants to merge 14 commits intomui:masterfrom
Conversation
[docs] Add v0.15.3 to the versions.json
|
@petermikitsh The animation here can be changed to include the textbox underline, that's not a big deal. The big deal is that this also adds keyboard support to DropDownMenu's that are NOT inside of a SelectField as well. Go to |
|
I get the technical benefits to this PR, but I visually prefer #4871. Maybe we could get the best of both worlds and combine the two? |
|
@petermikitsh in |
|
Yeah, lines 234 and 238 prevent |
|
@petermikitsh Right, i re-focus on the drop down close too (inside of DropDownMenu instead) but a new prop doesn't fix anything if you're focusing the DropDownMenu instead of the TextField (which is what should happen). If you focus the DropDownMenu again TextBox still re-renders and the focus ends in no-where-land. The only reason #4871 works with an extra prop is because the TextBox holds the focus and not the DropDownMenu and that's the whole problem I have with that pull. Both pull's have problems, and I don't care which gets accepted, but IMO the right solution is finding a way to handle focus events in DropDownMenu, and bubble the events up to TextField without screwing up the active element. |
|
Probably a dumb question, but why is there both a http://www.material-ui.com/#/components/dropdown-menu They seem visually and functionally identical. <DropDownMenu value={this.state.value} onChange={this.handleChange}>
<MenuItem value={1} primaryText="Never" />
<MenuItem value={2} primaryText="Every Night" />
<MenuItem value={3} primaryText="Weeknights" />
<MenuItem value={4} primaryText="Weekends" />
<MenuItem value={5} primaryText="Weekly" />
</DropDownMenu><SelectField value={this.state.value} onChange={this.handleChange}>
<MenuItem value={1} primaryText="Never" />
<MenuItem value={2} primaryText="Every Night" />
<MenuItem value={3} primaryText="Weeknights" />
<MenuItem value={4} primaryText="Weekends" />
<MenuItem value={5} primaryText="Weekly" />
</SelectField> |
|
@petermikitsh DropDownMenu has a wider use-case than SelectField. DropDownMenu could, for instance, be a drop down of links that upon click direct you to different pages. SelectField is for form input where the user can change the selected value (which is not necessarily true of DropDownMenu). DropDownMenu is important, especially for writing your own components with custom function as SelectField is locked into the purpose of being an input essentially. |
|
I don't know why this is a debate. Clearly #4871 breaks the re-usability of DropDownMenu, and for what? a different visual style? |
|
Does #4871 break |
|
Give me a second, I'm making more changes. |
|
It doesn't break what's already there, but accessibility of DropDownMenu and SelectField has been on the issue tracker for a while and #4871 will need to be reverted if keyboard support is ever to be added to DropDownMenu and that doesn't make sense since this pull already addresses both components. |
I just merged our two branches and that seems to not be the case. |
|
For sake of parity, I can support this change set over #4871. |
|
Don't worry too much about the future because there is a semi-rewrite coming up in the next few months. The semi-rewrite is being done with not just keyboard accessibility in mind, but I am also testing every single component with a screen reader. |
53b828e to
ea2538e
Compare
|
@petermikitsh If you check I've fixed the visual style so that it underlines the textbox as well how you like! @nathanmarks So does that mean this won't get accepted? should I also open a pull request that adds keyboard support to the DatePicker component or is it the same situation there? |
|
@caesay they'll definitely still be accepted, there is another breaking release coming for Underlying components such as In addition to fixing keyboard accessibility for menus, I've also added in a critical UX feature that we are currently missing: opening menus to the currently selected item. |
|
@nathanmarks is the breaking change part of the |
|
I decided to go ahead and review it myself, and found a number of problems with my controlled component, evidenced by this GIF:
|
|
@petermikitsh you closed PR#4871 in favor of this. But there is useful feature at that PR - onClose prop for DropDown component. It would be prefect to save it. |
|
Did this ever make it into a release? |
|
I'd like to know if this is going to be released as well. The ability to tab to a select field when filling out a form is a necessity for my project. If this will not be released I'll take a stab at implementing it myself and will submit a PR. Here is a bug for the issue: #5498 |
|
My project also would benefit greatly form this PR. |
|
I have opened #5921 to bring this PR into master. Any feedback is welcomed 🙏 . |



This adds keyboard support natively to
DropDownMenu, and alsoSelectFieldby extension.This (I think) is a better option than this pull request because it adds the keyboard support to all DropDownMenu's instead of SelectField.
DropDownMenu now has an IconButton that can receive (and indicate) focus. space or down arrow will open the drop down, and enter or esc will close the drop down.