Skip to content

Commit

Permalink
fix(select): pass event as first argument in onchange handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbien committed Apr 11, 2020
1 parent d372912 commit c862996
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ const Slider = React.forwardRef(function Slider(props, ref) {
setFocusVisible(true);

if (onChange) {
onChange(newValue);
onChange(event, newValue);
}
if (onChangeCommitted) {
onChangeCommitted(newValue);
onChangeCommitted(event, newValue);
}
});

Expand Down Expand Up @@ -396,7 +396,7 @@ const Slider = React.forwardRef(function Slider(props, ref) {
setFocusVisible(true);

if (onChange) {
onChange(newValue);
onChange(event, newValue);
}
});
const handleTouchEnd = useEventCallback(event => {
Expand All @@ -409,7 +409,7 @@ const Slider = React.forwardRef(function Slider(props, ref) {
const newValue = getNewValue(finger);

if (onChangeCommitted) {
onChangeCommitted(newValue);
onChangeCommitted(event, newValue);
}

touchId.current = undefined;
Expand All @@ -434,7 +434,7 @@ const Slider = React.forwardRef(function Slider(props, ref) {
setFocusVisible(true);

if (onChange) {
onChange(newValue);
onChange(event, newValue);
}
const doc = ownerDocument(sliderRef.current);
doc.addEventListener('mousemove', handleTouchMove);
Expand All @@ -456,7 +456,7 @@ const Slider = React.forwardRef(function Slider(props, ref) {
setFocusVisible(true);

if (onChange) {
onChange(newValue);
onChange(event, newValue);
}

const doc = ownerDocument(sliderRef.current);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Slider/Slider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ describe('<Slider />', () => {
);

expect(handleChange).toHaveBeenCalledTimes(2);
expect(handleChange.mock.calls[0][0]).toBe(80);
expect(handleChange.mock.calls[1][0]).toBe(78);
expect(handleChange.mock.calls[0][1]).toBe(80);
expect(handleChange.mock.calls[1][1]).toBe(78);
});
});

Expand Down

0 comments on commit c862996

Please sign in to comment.