Skip to content

Error not able to select minimum Date after selecting future date, onConfirm is wrong #880

Open
@0949328231

Description

@0949328231

Describe the bug

6201942573739.mp4

Expected behavior
I want to reselect the minimumDate, after selecting any date in the future
To Reproduce
Add example code that reproduces the behavior.

function parseDateStringToDate(dateString: string): Date {
  if (!dateString) {
    return new Date();
  }
  const parts = dateString.split('/').map(part => parseInt(part, 10));
  // parts[0] is day, parts[1] is month, parts[2] is year
  // Note: months are 0-based in JavaScript Date, so subtract 1
  return new Date(parts[2], parts[1] - 1, parts[0]);
}
<DatePicker
      modal
      mode={'date'}
      open={open}
      locale="vi"
      date={parseDateStringToDate(value)}
      onConfirm={date => {
        console.log('onConfirm', date, moment(date).format('DD/MM/YYYY'));
        onClose();
        setValue(moment(date).format('DD/MM/YYYY'));
      }}
      title={null}
      confirmText="Lưu"
      cancelText="Hủy"
      minimumDate={new Date()}
      onCancel={onClose}
    />

Smartphone (please complete the following information):

  • OS: [Android or iOS]
  • React Native version 0.73.9
  • react-native-date-picker version ^5.0.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions