wix / react-native-ui-lib

UI Components Library for React Native
https://wix.github.io/react-native-ui-lib/
MIT License
6.44k stars 706 forks source link

Incubator.WheelPicker only calls onChange every other time #2356

Closed sseppola closed 1 year ago

sseppola commented 1 year ago

Description

Incubator/WheelPicker it only calls onChange every other time.

Related to

Steps to reproduce

Render WheelPicker and scroll to multiple different values. See video.

Expected behavior

onChange should be called every time the picker stops.

Actual behavior

The picker only calls onChange every other time

More Info

Code snippet

import WheelPicker from 'react-native-ui-lib/src/incubator/WheelPicker';
import {range} from 'lodash';

export const Demo = () => {
    const reminderIntervalOptions = range(30, 135, 15).map(value => ({
        value,
        label: `${value} minutes`,
    }));

    const [reminderIntervalInMinutes, set_reminderIntervalInMinutes] = React.useState(
        notifications.reminderIntervalInMinutes,
    );

    return (
        <WheelPicker
          initialValue={reminderIntervalInMinutes}
          items={reminderIntervalOptions}
          activeTextColor={'green'}
          inactiveTextColor={'gainsboro'}
          onChange={(value: number) => {
            set_reminderIntervalInMinutes(value);
          }}
        />
    )
}

Screenshots/Video

https://user-images.githubusercontent.com/4065840/205452380-73598fa4-de13-4471-9ae6-96304b3f5c6e.mov

Environment

Affected platforms

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ckachelmeier commented 8 months ago

We had the same issue in our application. It was an issue with resetting the initialValue all the time. So things along the lines of initialValue={currentValue} seem to cause this issue.

asevims commented 5 months ago

I have the same issue.