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

Set currentDate to be prop.minimumDate if not null or the current date. #726

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andvalsol
Copy link

Overview

For iOS if the user hasn't touched the picker, the default date is set to be the date when the picker was mounted, instead of setting the date to be the minimum date (if passed), else the current date should be selected, since the mounting of the date could be at 11:59pm and the re-render could have been at 12:00am.

Test Plan

  1. Open the picker on iOS
  2. Set the minimum date to be a different date from the current date.
  3. The picker's selected date (when clicking confirm) the returned should be the minimum date as expected, also the picker should behave as usual when other actions are taken.

@mmazzarolo
Copy link
Owner

mmazzarolo commented Dec 3, 2023

Maybe I'm missing something but doesn't this defeat the purpose of having the date prop?

image

@andvalsol andvalsol force-pushed the Fix/ios-timepicker-default-date branch from ce8257c to 3d27277 Compare December 4, 2023 00:59
@andvalsol andvalsol force-pushed the Fix/ios-timepicker-default-date branch from 3d27277 to e43622d Compare December 4, 2023 01:02
@andvalsol
Copy link
Author

Maybe I'm missing something but doesn't this defeat the purpose of having the date prop?
image

I've added a change in the PR, this change corresponds to the behaviour the datetime picker seems to work on iOS

@andvalsol
Copy link
Author

I've changed the PR.

@mmazzarolo
Copy link
Owner

mmazzarolo commented Dec 5, 2023

Will review soon. FYI, this can also be done directly outside of the library:

setState({
  isPickerOpen: true, // var that drives the picker visibility
  pickerDate: date > minimumDate ? date : minimumDate // `date` prop passed to the picker
})

@andvalsol
Copy link
Author

yes, but, well I feel that by doing this the library would match the behaviour of the modal in iOS, also the warning is quite handy 😄

@andvalsol
Copy link
Author

@mmazzarolo have you got the chance to review the changes?

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

Successfully merging this pull request may close these issues.

None yet

2 participants