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

[material-ui][Slider] Set CSS writing-mode and update vertical slider docs #44537

Merged
merged 22 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3f04e20
Slider sets CSS writing-mode
mj12albert Nov 25, 2024
419c8d9
Fix CI
mj12albert Nov 25, 2024
7b6646e
Fix PR comments
mj12albert Nov 25, 2024
9dc7bf7
Fix grammar
mj12albert Nov 25, 2024
5a25a2d
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Nov 25, 2024
e317872
Add a test
mj12albert Nov 25, 2024
fdc1487
Fix keydown handling
mj12albert Nov 25, 2024
57af0e8
Handle all keypresses
mj12albert Nov 26, 2024
699ace5
Merge remote-tracking branch 'upstream/master' into fix/vertical-slid…
mj12albert Nov 26, 2024
e0ac8e1
Merge remote-tracking branch 'upstream/master' into fix/vertical-slid…
mj12albert Nov 27, 2024
93083a8
Consolidate keyboard interaction tests
mj12albert Nov 27, 2024
cc32deb
Use strings for keys
mj12albert Nov 27, 2024
415c1ad
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Nov 28, 2024
7f5ff37
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Nov 29, 2024
1979ca9
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Nov 29, 2024
e1db01a
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Nov 30, 2024
f3261d6
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Dec 2, 2024
e5371ea
Merge remote-tracking branch 'upstream/master' into fix/vertical-slid…
mj12albert Dec 3, 2024
f463c0f
Fixes
mj12albert Dec 3, 2024
9f9587c
Fix grammar
mj12albert Dec 3, 2024
c279aea
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Dec 3, 2024
7981bcc
Merge branch 'master' into fix/vertical-slider-a11y
mj12albert Dec 10, 2024
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 @@ -17,7 +17,6 @@ import RangeSlider from '../../../../../../docs/data/material/components/slider/
import SliderSizes from '../../../../../../docs/data/material/components/slider/SliderSizes';
import TrackFalseSlider from '../../../../../../docs/data/material/components/slider/TrackFalseSlider';
import TrackInvertedSlider from '../../../../../../docs/data/material/components/slider/TrackInvertedSlider';
import VerticalAccessibleSlider from '../../../../../../docs/data/material/components/slider/VerticalAccessibleSlider';
import VerticalSlider from '../../../../../../docs/data/material/components/slider/VerticalSlider';

export default function Slider() {
Expand Down Expand Up @@ -125,12 +124,6 @@ export default function Slider() {
<TrackInvertedSlider />
</div>
</section>
<section>
<h2> Vertical Accessible Slider</h2>
<div className="demo-container">
<VerticalAccessibleSlider />
</div>
</section>
<section>
<h2> Vertical Slider</h2>
<div className="demo-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import RangeSlider from '../../../../../docs/data/material/components/slider/Ran
import SliderSizes from '../../../../../docs/data/material/components/slider/SliderSizes.tsx';
import TrackFalseSlider from '../../../../../docs/data/material/components/slider/TrackFalseSlider.tsx';
import TrackInvertedSlider from '../../../../../docs/data/material/components/slider/TrackInvertedSlider.tsx';
import VerticalAccessibleSlider from '../../../../../docs/data/material/components/slider/VerticalAccessibleSlider.tsx';
import VerticalSlider from '../../../../../docs/data/material/components/slider/VerticalSlider.tsx';

export default function Slider() {
Expand Down Expand Up @@ -126,12 +125,6 @@ export default function Slider() {
<TrackInvertedSlider />
</div>
</section>
<section>
<h2> Vertical Accessible Slider</h2>
<div className="demo-container">
<VerticalAccessibleSlider />
</div>
</section>
<section>
<h2> Vertical Slider</h2>
<div className="demo-container">
Expand Down
28 changes: 0 additions & 28 deletions docs/data/material/components/slider/VerticalAccessibleSlider.js

This file was deleted.

28 changes: 0 additions & 28 deletions docs/data/material/components/slider/VerticalAccessibleSlider.tsx

This file was deleted.

This file was deleted.

50 changes: 25 additions & 25 deletions docs/data/material/components/slider/VerticalSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,13 @@ import * as React from 'react';
import Stack from '@mui/material/Stack';
import Slider from '@mui/material/Slider';

function valuetext(value) {
return `${value}°C`;
}

const marks = [
{
value: 0,
label: '0°C',
},
{
value: 20,
label: '20°C',
},
{
value: 37,
label: '37°C',
},
{
value: 100,
label: '100°C',
},
];

export default function VerticalSlider() {
return (
<Stack sx={{ height: 300 }} spacing={1} direction="row">
<Slider
aria-label="Temperature"
orientation="vertical"
getAriaValueText={valuetext}
getAriaValueText={getAriaValueText}
valueLabelDisplay="auto"
defaultValue={30}
/>
Expand All @@ -45,11 +22,34 @@ export default function VerticalSlider() {
<Slider
getAriaLabel={() => 'Temperature'}
orientation="vertical"
getAriaValueText={valuetext}
getAriaValueText={getAriaValueText}
defaultValue={[20, 37]}
valueLabelDisplay="auto"
marks={marks}
/>
</Stack>
);
}

function getAriaValueText(value) {
return `${value}°C`;
}

const marks = [
{
value: 0,
label: '0°C',
},
{
value: 20,
label: '20°C',
},
{
value: 37,
label: '37°C',
},
{
value: 100,
label: '100°C',
},
];
50 changes: 25 additions & 25 deletions docs/data/material/components/slider/VerticalSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,13 @@ import * as React from 'react';
import Stack from '@mui/material/Stack';
import Slider from '@mui/material/Slider';

function valuetext(value: number) {
return `${value}°C`;
}

const marks = [
{
value: 0,
label: '0°C',
},
{
value: 20,
label: '20°C',
},
{
value: 37,
label: '37°C',
},
{
value: 100,
label: '100°C',
},
];

export default function VerticalSlider() {
return (
<Stack sx={{ height: 300 }} spacing={1} direction="row">
<Slider
aria-label="Temperature"
orientation="vertical"
getAriaValueText={valuetext}
getAriaValueText={getAriaValueText}
valueLabelDisplay="auto"
defaultValue={30}
/>
Expand All @@ -45,11 +22,34 @@ export default function VerticalSlider() {
<Slider
getAriaLabel={() => 'Temperature'}
orientation="vertical"
getAriaValueText={valuetext}
getAriaValueText={getAriaValueText}
defaultValue={[20, 37]}
valueLabelDisplay="auto"
marks={marks}
/>
</Stack>
);
}

function getAriaValueText(value: number) {
return `${value}°C`;
}

const marks = [
{
value: 0,
label: '0°C',
},
{
value: 20,
label: '20°C',
},
{
value: 37,
label: '37°C',
},
{
value: 100,
label: '100°C',
},
];
19 changes: 12 additions & 7 deletions docs/data/material/components/slider/slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,22 @@

## Vertical sliders

Set the `orientation` prop to `"vertical"` to create vertical sliders. The thumb will track vertical movement instead of horizontal movement.

Check warning on line 101 in docs/data/material/components/slider/slider.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/material/components/slider/slider.md", "range": {"start": {"line": 101, "column": 82}}}, "severity": "WARNING"}

{{"demo": "VerticalSlider.js"}}

**WARNING**: Chrome, Safari and newer Edge versions that is any browser based on WebKit exposes `<Slider orientation="vertical" />` as horizontal ([chromium issue #40736841](https://issues.chromium.org/issues/40736841)).
By applying `-webkit-appearance: slider-vertical;` the slider is exposed as vertical.
:::warning
Chrome versions below 124 implement `aria-orientation` incorrectly for vertical sliders and expose them as `'horizontal'` in the accessibility tree. ([Chromium issue #40736841](https://issues.chromium.org/issues/40736841))

The `-webkit-appearance: slider-vertical` CSS property can be used to correct this for these older versions, with the trade-off of causing a console warning in newer Chrome versions:

However, by applying `-webkit-appearance: slider-vertical;` keyboard navigation for horizontal keys (<kbd class="key">Arrow Left</kbd>, <kbd class="key">Arrow Right</kbd>) is reversed ([chromium issue #40739626](https://issues.chromium.org/issues/40739626)).
Usually, up and right should increase and left and down should decrease the value.
If you apply `-webkit-appearance` you could prevent keyboard navigation for horizontal arrow keys for a truly vertical slider.
This might be less confusing to users compared to a change in direction.
```css
.MuiSlider-thumb input {
-webkit-appearance: slider-vertical;
}
```

{{"demo": "VerticalAccessibleSlider.js"}}
:::

## Marks placement

Expand Down
Loading
Loading