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

[ANDROID] If the minimumDate and maximumDate are set on 'date' mode, by openening the datepicker it shows the minimumDate, not the maximumDate #779

Open
angelinaromashkoo opened this issue Mar 6, 2024 · 7 comments

Comments

@angelinaromashkoo
Copy link

angelinaromashkoo commented Mar 6, 2024

If I set the minimumDate and maximumDate on Android, when I open the Datepicker, it will show me the dates starting from the minimum date (instead of showing me the maximum date like it happens on iOS). So for example, I set the minimumDate to be '1924-03-06' and the maximumDate is '2007-03-06'. When I open the datepicker on Android I see this (6st March 1924 is the minimum date, not the selected one). On IOS it works perfect
ANDROID
Screenshot 2024-03-06 at 17 25 25

IOS
Screenshot 2024-03-06 at 17 25 56

The expected behaviour would be to see when I open the datepicker on 'date' mode the maximum date, even if the minimumDate is set

<DatePicker
        modal
        mode="date"
        locale={i18next.language}
        open={datePickerOpen}
        date={
          dateOfBirth !== ''
            ? DateTime.fromISO(dateOfBirth).setLocale(i18next.language).toJSDate()
            : DateTime.now().setZone('utc').setLocale(i18next.language).toJSDate()
        }
        onConfirm={onSelectDateOfBirth}
        onCancel={toggleDatePicker}
        maximumDate={minDate}
        minimumDate={maxDate}
      />
  • OS: Android
  • React Native version: "0.71.13"
  • react-native-date-picker version: 4.3.3
@linhkiubo98
Copy link

Same issuse :(

@VaibhavValere
Copy link

Is there any workaround for this?

@linhkiubo98
Copy link

Is there any workaround for this?

You need to adjust either the start date or the selected date to fall within the selectable range of values.

@Ammarlio
Copy link

You have to set the date property value the same as the maximumDate property value

@Sandeep145XamRN
Copy link

Same issue, any update on solution, android specific issue.

@danhidsan
Copy link

Same issue. Is there update about this?

@Sandeep145XamRN
Copy link

@danhidsan please refer to @Ammarlio comment.
Ensure that the date prop is passed in the same format as the maximumDate prop.

Example:
const [date, setDate] = useState(new Date(new Date().setFullYear(new Date().getFullYear() - 10)));
const [open, setOpen] = useState(false);
<DatePicker
modal
open={open}
date={date}
mode={'date'}
maximumDate={new Date(new Date().setFullYear(new Date().getFullYear() - 10))}
onConfirm={newDate => { setOpen(false); setDate(newDate) }}
onCancel={() => { setOpen(false); }}
/>

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

6 participants