Skip to content

fix onValueChanges is called on programmatic value changes on Android #409

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

Closed
wants to merge 2 commits into from
Closed
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 @@ -108,7 +108,7 @@ public void onStopTrackingTouch(SeekBar seekbar) {
new ReactSliderEvent(
seekbar.getId(),
((ReactSlider)seekbar).toRealProgress(seekbar.getProgress()),
!((ReactSlider)seekbar).isSliding()));
false));
}
};

Expand Down
9 changes: 8 additions & 1 deletion package/src/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,14 @@ const SliderComponent = (

const onValueChangeEvent = onValueChange
? (event: Event) => {
onValueChange(event.nativeEvent.value);
let userEvent = true;
if (Platform.OS === 'android') {
// On Android there's a special flag telling us the user is
// dragging the slider.
userEvent =
event.nativeEvent.fromUser != null && event.nativeEvent.fromUser;
}
userEvent && onValueChange(event.nativeEvent.value);
}
: null;

Expand Down