-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Button] No standard keyboard focus API for buttons #3008
Comments
@puzzfuzz Thanks for opening this issue, with a summarized situation.
Here is my perspective
import React from 'react';
import ReactDOM from 'react-dom';
import FlatButton from 'material-ui/FlatButton';
class MyComponent extends React.Component {
componentDidMount() {
ReactDOM.findDOMNode(this.button).focus(); // Set the correct `document.activeElement`
}
render() {
return <FlatButton ref={(node) => this.button = node } label="label" />;
}
}
export default MyComponent;
I think that we should be supporting 2. for the Regarding @mzamoras I'm closing #6268 until we agree on the right path going forward. |
@oliviertassinari I understand your point but:
I know you are focusing your efforts on the next development, but right now it'll be helpful to grant the same level of access for buttons either remove it or enable it for both. Or if you could suggest me a way to programmatically achieve the same result as pressing tab key to reach a button. I just want to load a view and automatically focus a FlatButton, including the ripple effect and everything ... that would be amazingly helpful, which by the way is possible only with RaisedButton. |
I guess it's used internally by the component.
That's true, the visual feedback is only added when the focus is acquired through a keyboard interaction. That's by design.
You have the |
I am attempting to build a webapp that relies 100% on synthetic or keyboard navigation. The UX is kind of like that of a video game where a user can pop in and out of menus and use the controller sticks to navigate focus around a bunch of interactive button, menus, etc. I've built my own focus management stack (so not asking for general keyboard / tab-order accessibility here), but I'm finding that the support for either stateful or programmatic focus management of MUI button components is inconsistent at best, and often non-existent.
The
EnhancedButton
component has a pair ofset/removeKeyboardFocus
functions that work well for my purposes, however the various higher-order button components that wrapEnhancedButton
either hide or obscure this functionality or occasionally partially implement it.EnhancedButton
supports setting keyboard focus via props, however it will not unset it and most higher-order buttons rely on simply proxying props down to theEnhancedButton
so this doesn't work.IconButton
has asetKeyboardFocus
method (which delegates to theEnhancedButton
it wraps viathis.refs
) however it does not have aremoveKeyboardFunction
analogEnhancedButton
via refs as"button"
, so I can get there by doingthis.refs['myIconnBtn42'].refs.button.setKeyboardFocus()
but this feels pretty wrongRaisedButton
has no programmatic supportEnhancedButton
via refs as"container"
, so I can do as above, but it's a different ref name, so I have to interrogate the ref chain to see where to make this callFlatButton
does not have a programmatic API for this, nor does it expose its wrappedEnhancedButton
whatsoever.It would be great if all the buttons either proxied the
set/removeKeyboardFocus
functions consistently, or exposed their wrappedEnhancedButton
as a ref via a consistent name.The text was updated successfully, but these errors were encountered: