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

[Button] Fix visual focus state according to spec #13134

Closed

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Oct 7, 2018

Breaking change

  • Button has no focus ripple by default
- <Button />
+ <Button focusRipple />

Deprecation

  • deprecate disableFocusRipple

Changes

  • Buttons have the "correct" visual focus state
  • deprecatedPropType does not cache warnings in test environment

Button demos in latest vs. this pr

Some variations on this PR:

  • don't deprecate disableFocusRipple (although it adds quite a bit of complexity to a non-standard behavior)
  • remove focus ripple immediately (should at least add an example with focus ripple that is doable in userland)

Future work:

@eps1lon eps1lon added component: button This is the name of the generic UI component, not the React module! deprecation New deprecation message labels Oct 7, 2018
@eps1lon eps1lon force-pushed the fix/core/Button/visual-focused-state branch 3 times, most recently from 9cab252 to 248cdde Compare October 7, 2018 13:35
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",
Copy link
Member

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?

Copy link
Member Author

@eps1lon eps1lon Oct 7, 2018

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?

Copy link
Member

@oliviertassinari oliviertassinari Oct 8, 2018

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.',
Copy link
Member

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?

Copy link
Member Author

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,
Copy link
Member

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.

Copy link
Member Author

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

@eps1lon eps1lon force-pushed the fix/core/Button/visual-focused-state branch from 0bd2389 to 2673e9f Compare October 7, 2018 17:25
@mbrookes
Copy link
Member

mbrookes commented Oct 7, 2018

Something doesn't look right with the API docs:

image

@eps1lon eps1lon added the design: material This is about Material Design, please involve a visual or UX designer in the process label Oct 7, 2018
@eps1lon
Copy link
Member Author

eps1lon commented Oct 7, 2018

@mbrookes Should be fixed now. Matching of deprecated props is done on text only which did not support whitespace.

@@ -24,7 +24,7 @@ import Button from '@material-ui/core/Button';
| <span class="prop-name">color</span> | <span class="prop-type">enum:&nbsp;'default'&nbsp;&#124;<br>&nbsp;'inherit'&nbsp;&#124;<br>&nbsp;'primary'&nbsp;&#124;<br>&nbsp;'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:&nbsp;string&nbsp;&#124;<br>&nbsp;func&nbsp;&#124;<br>&nbsp;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. |
Copy link
Member

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).

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

???

image

@eps1lon eps1lon added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Oct 8, 2018
@eps1lon eps1lon force-pushed the fix/core/Button/visual-focused-state branch from aa75f05 to d8f5f45 Compare January 15, 2019 12:17
@eps1lon eps1lon added breaking change and removed PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Jan 15, 2019
@eps1lon
Copy link
Member Author

eps1lon commented Jan 15, 2019

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

@oliviertassinari
Copy link
Member

What's the status of this pull request?

@eps1lon eps1lon added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 3, 2019
@eps1lon
Copy link
Member Author

eps1lon commented Apr 3, 2019

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.

@oliviertassinari
Copy link
Member

@eps1lon Do we move the effort to v5?

@eps1lon
Copy link
Member Author

eps1lon commented Apr 3, 2019

@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.

@eps1lon
Copy link
Member Author

eps1lon commented Jul 3, 2019

Revisiting this once work for implementing States begins.

@eps1lon eps1lon closed this Jul 3, 2019
@eps1lon eps1lon deleted the fix/core/Button/visual-focused-state branch September 14, 2021 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: button This is the name of the generic UI component, not the React module! deprecation New deprecation message design: material This is about Material Design, please involve a visual or UX designer in the process PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants