Skip to content

Commit

Permalink
[Slider] Fix cannot read property ‘focus’ of nulll
Browse files Browse the repository at this point in the history
  • Loading branch information
annabic committed Jul 2, 2020
1 parent 3a96473 commit 200721a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/material-ui/src/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function roundValueToStep(value, step, min) {

function setValueIndex({ values, source, newValue, index }) {
// Performance shortcut
if (values[index] === newValue) {
if (source[index] === newValue) {
return source;
}

Expand Down
18 changes: 18 additions & 0 deletions packages/material-ui/src/Slider/Slider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,24 @@ describe('<Slider />', () => {
});
});

it('should not break when initial value is out of range', () => {
const { container } = render(<Slider value={[19, 41]} min={20} max={40} />);

stub(container.firstChild, 'getBoundingClientRect').callsFake(() => ({
width: 100,
height: 10,
bottom: 10,
left: 0,
}));

fireEvent.touchStart(
container.firstChild,
createTouches([{ identifier: 1, clientX: 100, clientY: 0 }]),
);

fireEvent.touchMove(document.body, createTouches([{ identifier: 1, clientX: 20, clientY: 0 }]));
});

describe('prop: step', () => {
it('should handle a null step', () => {
const { getByRole, container } = render(
Expand Down

0 comments on commit 200721a

Please sign in to comment.