-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Fix visual focus state according to spec #13134
Conversation
9cab252
to
248cdde
Compare
package.json
Outdated
@@ -125,6 +125,7 @@ | |||
"nyc": "^13.0.0", | |||
"postcss": "^7.0.0", | |||
"prettier": "^1.8.2", | |||
"prop-types-extra": "^1.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package isn't bundle size friendly, for instance:
https://github.com/mui-org/material-ui/blob/965776002fcf482b65d66040393cf75caa18d356/packages/material-ui/src/utils/exactProp.js#L9-L12. What do you think of inlining it as we did in v0.x?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oliviertassinari
I didn't really look into but isn't the hole propTypes
object removed in production i.e. it doesn't matter how many dependencies propTypes
pulls in because they will be stripped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The imports aren't striped, at least not in the wrap mode.
disableRipple: PropTypes.bool, | ||
disableRipple: deprecated( | ||
PropTypes.bool, | ||
'Focus ripple will be removed because it does not follow Material design.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. We do want to keep the ripple. It's the pulsating focusing ripple we want to remove no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. That should be at disableFocusRipple
.
@@ -365,7 +387,7 @@ Button.defaultProps = { | |||
color: 'default', | |||
component: 'button', | |||
disabled: false, | |||
disableFocusRipple: false, | |||
disableFocusRipple: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we wait for a minor or can it be released in a patch? I would vote for a minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably any choice would be wrong. It's a fix if you want strict material design but breaking if you rely on a focus ripple for some reason. Minor sounds like a good compromise
0bd2389
to
2673e9f
Compare
@mbrookes Should be fixed now. Matching of deprecated props is done on text only which did not support whitespace. |
pages/api/button.md
Outdated
@@ -24,7 +24,7 @@ import Button from '@material-ui/core/Button'; | |||
| <span class="prop-name">color</span> | <span class="prop-type">enum: 'default' |<br> 'inherit' |<br> 'primary' |<br> 'secondary'<br> | <span class="prop-default">'default'</span> | The color of the component. It supports those theme colors that make sense for this component. | | |||
| <span class="prop-name">component</span> | <span class="prop-type">union: string |<br> func |<br> object<br> | <span class="prop-default">'button'</span> | The component used for the root node. Either a string to use a DOM element or a component. | | |||
| <span class="prop-name">disabled</span> | <span class="prop-type">bool | <span class="prop-default">false</span> | If `true`, the button will be disabled. | | |||
| <span class="prop-name">disableFocusRipple</span> | <span class="prop-type">bool | <span class="prop-default">false</span> | If `true`, the keyboard focus ripple will be disabled. `disableRipple` must also be true. | | |||
| ~~<span class="prop-name">disableFocusRipple</span>~~ | <span class="prop-type">bool | <span class="prop-default">true</span> | *Deprecated*. Focus ripple will be removed because it does not follow Material design.<br><br>If `true`, the keyboard focus ripple will be disabled. `disableRipple` must also be true. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm being over sensitive, but it isn't that it doesn't follow Material Design, so much that the spec has changed since this component was written. (For the worse IMHO. And not saying I'm a big fan of the focus ripple, but the subtle shade change is not enough to distinguish which component is focused).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbrookes I would agree on that with contained
and fab
buttons. One of the issues here is that hover and focus states are not correct in the first place since the actual button should always be opaque.
Maybe we should rework this and lighten or darken those states instead of adding opacity. That might improve focus visibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And text
.
Put a text
button next to an outlined
button, and focus the text
button. To the uninitiated, which one is focused? The focused text
button looks like a (lightly) filled
button, with neither focused.
While the focus ripple might be unattractive, it's visually distinctive, and draws attention to the focused element (much as the native browser highlight does). I guess in the google employee churn, that critical requirement got lost, and the v2 focus state is the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a fair comparison to put an outlined button next to a text button. I will work on it again and see how it looks without opacity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aa75f05
to
d8f5f45
Compare
Test is passing locally and failing with different callcounts on CI in test_browsers and test_unit. Seems like spying on console.error doesn't integrate well with mocha |
What's the status of this pull request? |
I'll need to look into that again. It doesn't have that high of a priority since we deprioritized spec changes and this likely needs a bigger picture approach i.e. implement states according to spec. I would like to leave this open if somebody wants to pick this up. |
@eps1lon Do we move the effort to v5? |
Probably. Maybe we can move this into a feature release since matching the spec is more of a bug fix but we'll see when we get there. |
Revisiting this once work for implementing States begins. |
Breaking change
Button
has no focus ripple by defaultDeprecation
disableFocusRipple
Changes
deprecatedPropType
does not cache warnings in test environmentButton demos in latest vs. this pr
Some variations on this PR:
disableFocusRipple
(although it adds quite a bit of complexity to a non-standard behavior)Future work:
theme
. From what I gathered e.g. hover does not add opacity but an overlay to the button which has its own color and opacity.