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] Fix positioning of tooltips on vertical slider #32919

Merged
merged 5 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function VerticalSlider() {
orientation="vertical"
defaultValue={30}
aria-label="Temperature"
valueLabelDisplay="auto"
onKeyDown={preventHorizontalKeyboardNavigation}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function VerticalSlider() {
orientation="vertical"
defaultValue={30}
aria-label="Temperature"
valueLabelDisplay="auto"
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure about this change? Why not keep the default value?

Copy link
Member

Choose a reason for hiding this comment

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

With it, developers can see how the value tooltips look like on vertical sliders. I'd keep them.

Copy link
Member

@oliviertassinari oliviertassinari Jun 1, 2022

Choose a reason for hiding this comment

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

It feels like we made this change only to test & develop the fix. I wonder if a general rule should be to either make it the default behavior or remove the prop in the demos (instead, replacing it with a dedicated demo) 😁.

onKeyDown={preventHorizontalKeyboardNavigation}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
orientation="vertical"
defaultValue={30}
aria-label="Temperature"
valueLabelDisplay="auto"
onKeyDown={preventHorizontalKeyboardNavigation}
/>
3 changes: 3 additions & 0 deletions docs/data/material/components/slider/VerticalSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ export default function VerticalSlider() {
aria-label="Temperature"
orientation="vertical"
getAriaValueText={valuetext}
valueLabelDisplay="auto"
defaultValue={30}
/>
<Slider
aria-label="Temperature"
orientation="vertical"
defaultValue={30}
valueLabelDisplay="auto"
disabled
/>
<Slider
getAriaLabel={() => 'Temperature'}
orientation="vertical"
getAriaValueText={valuetext}
defaultValue={[20, 37]}
valueLabelDisplay="auto"
marks={marks}
/>
</Stack>
Expand Down
3 changes: 3 additions & 0 deletions docs/data/material/components/slider/VerticalSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ export default function VerticalSlider() {
aria-label="Temperature"
orientation="vertical"
getAriaValueText={valuetext}
valueLabelDisplay="auto"
defaultValue={30}
/>
<Slider
aria-label="Temperature"
orientation="vertical"
defaultValue={30}
valueLabelDisplay="auto"
disabled
/>
<Slider
getAriaLabel={() => 'Temperature'}
orientation="vertical"
getAriaValueText={valuetext}
defaultValue={[20, 37]}
valueLabelDisplay="auto"
marks={marks}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const finalTheme = createTheme({
color: theme.palette.grey[500],
fontWeight: 700,
padding: 0,
left: '2rem',
left: '3rem',
}),
[`&.${sliderClasses.valueLabelOpen}`]: {
transform: 'none',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const finalTheme = createTheme({
color: theme.palette.grey[500],
fontWeight: 700,
padding: 0,
left: '2rem',
left: '3rem',
}),
[`&.${sliderClasses.valueLabelOpen}`]: {
transform: 'none',
Expand Down
38 changes: 27 additions & 11 deletions packages/mui-material/src/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ const SliderValueLabel = styled(SliderValueLabelUnstyled, {
transition: theme.transitions.create(['transform'], {
duration: theme.transitions.duration.shortest,
}),
top: -10,
transformOrigin: 'bottom center',
transform: 'translateY(-100%) scale(0)',
position: 'absolute',
Expand All @@ -320,20 +319,37 @@ const SliderValueLabel = styled(SliderValueLabelUnstyled, {
alignItems: 'center',
justifyContent: 'center',
padding: '0.25rem 0.75rem',
...(ownerState.orientation === 'horizontal' && {
top: '-10px',
'&:before': {
position: 'absolute',
content: '""',
width: 8,
height: 8,
transform: 'translate(-50%, 50%) rotate(45deg)',
backgroundColor: 'inherit',
bottom: 0,
left: '50%',
},
}),
...(ownerState.orientation === 'vertical' && {
right: '30px',
top: '25px',
'&:before': {
position: 'absolute',
content: '""',
width: 8,
height: 8,
transform: 'translate(-50%, 50%) rotate(45deg)',
backgroundColor: 'inherit',
right: '-20%',
top: '25%',
},
}),
...(ownerState.size === 'small' && {
fontSize: theme.typography.pxToRem(12),
padding: '0.25rem 0.5rem',
}),
'&:before': {
position: 'absolute',
content: '""',
width: 8,
height: 8,
bottom: 0,
left: '50%',
transform: 'translate(-50%, 50%) rotate(45deg)',
backgroundColor: 'inherit',
},
}));

SliderValueLabel.propTypes /* remove-proptypes */ = {
Expand Down