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

[iOS] minimumDate/maximumDate not working correctly when 2 time pickers have different configurations #863

Open
ladiandrasi opened this issue Oct 11, 2024 · 0 comments

Comments

@ladiandrasi
Copy link

ladiandrasi commented Oct 11, 2024

Describe the bug
We have multiple time pickers with different min/max configurations. For example:

  • User interacts with time picker A that has a maximum time of "15:00". This works fine ✅
  • User interacts with time picker B that has no maximum date. The result is that only a few hours are available to be selected in the time picker.

After doing some debugging it seems the issue is with the following code in RNDatePicker.mm:

    // maximumDate
    if(oldViewProps.maximumDate != newViewProps.maximumDate) {
        [_picker setMaximumDate: unixMillisToNSDate(newViewProps.maximumDate)];
    }
    
    //  minimumDate
    if(oldViewProps.minimumDate != newViewProps.minimumDate) {
        [_picker setMinimumDate: unixMillisToNSDate(newViewProps.minimumDate)];
    }
    

It seems that when interacting with time picker B:

  • oldViewProps.maximumDate is the maximumDate of time picker A
  • newViewProps.maximumDate is 0, even though in the JS code of time picker B this was explicitly passed in as maximumDate={null}

We currently applied the following patch, which works for us:

    // maximumDate
    if(oldViewProps.maximumDate != newViewProps.maximumDate) {
        if(newViewProps.maximumDate == 0) {
            [_picker setMaximumDate: nil];
        } else {
            [_picker setMaximumDate: unixMillisToNSDate(newViewProps.maximumDate)];
        }
    }
    
    //  minimumDate
    if(oldViewProps.minimumDate != newViewProps.minimumDate) {
        if(newViewProps.minimumDate == 0) {
            [_picker setMinimumDate: nil];
        } else {
            [_picker setMinimumDate: unixMillisToNSDate(newViewProps.minimumDate)];
        }
    }

Expected behavior
You can interact with multiple time pickers that have different min/max configurations.

Smartphone:

  • OS: iOS
  • React Native version 0.75.4
  • react-native-date-picker version 5.0.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant