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

[Slider] Increase interaction area #18429

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions packages/material-ui/src/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const styles = theme => ({
height: 2,
width: '100%',
boxSizing: 'content-box',
padding: '11px 0',
padding: '13px 0',
display: 'inline-block',
position: 'relative',
cursor: 'pointer',
Expand All @@ -152,7 +152,7 @@ export const styles = theme => ({
'&$vertical': {
width: 2,
height: '100%',
padding: '0 11px',
padding: '0 13px',
},
// The primary input mechanism of the device includes a pointing device of limited accuracy.
'@media (pointer: coarse)': {
Expand Down Expand Up @@ -247,11 +247,12 @@ export const styles = theme => ({
'&::after': {
position: 'absolute',
content: '""',
// reach 48px touch target (2 * 18 + thumb circumference)
left: -18,
top: -18,
right: -18,
bottom: -18,
borderRadius: '50%',
// reach 42px hit target (2 * 15 + thumb diameter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the 42px coming from?

Copy link
Member Author

@oliviertassinari oliviertassinari Nov 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a tradeoff to be closer to 44px without leaking too much from the dimension of the parent. 28px is a tradeoff to increase the interaction zone without changing too much the layout for existing users and still enabling dense layout.

I don't think that we should always follow the specification to the letter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you don't you have to explain how you arrive at these values. And not just some ephemeral "it's a tradeoff". Given the 8px grid this is now 3/4 of a unit instead of the 1/2 which is probably why the recommendation uses 44. Just go with the default to stay in the design system. Not following the default system is actually more likely to cause layout breakage.

Copy link
Member Author

@oliviertassinari oliviertassinari Nov 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can ignore the 4px grid for the thumb extension because it's not visible. By tradeoff, I mean, increase the slider height by the minimal grid unit: 4px, make the thumb "leak" by the minimum amount: 7px visually look almost too much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this "minimum amount" you talk about? How did you construct this number?

Copy link
Member Author

@oliviertassinari oliviertassinari Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4px is the grid unit, so we get 28/4 = 7.

left: -15,
top: -15,
right: -15,
bottom: -15,
},
'&$focusVisible,&:hover': {
boxShadow: `0px 0px 0px 8px ${fade(theme.palette.primary.main, 0.16)}`,
Expand Down Expand Up @@ -317,12 +318,12 @@ export const styles = theme => ({
...theme.typography.body2,
color: theme.palette.text.secondary,
position: 'absolute',
top: 22,
top: 26,
transform: 'translateX(-50%)',
whiteSpace: 'nowrap',
'$vertical &': {
top: 'auto',
left: 22,
left: 26,
transform: 'translateY(50%)',
},
'@media (pointer: coarse)': {
Expand Down