mmazzarolo / react-native-modal-datetime-picker

A React-Native datetime-picker for Android and iOS
MIT License
2.98k stars 399 forks source link

`onHide` callback doesn't return a valid Date #735

Open ElviraBurchik opened 9 months ago

ElviraBurchik commented 9 months ago

Environment

System:
  OS: macOS 13.5.2
  CPU: (8) arm64 Apple M1
  Memory: 100.00 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.2
    path: ~/.nvm/versions/node/v18.18.2/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 10.4.0
    path: ~/.nvm/versions/node/v18.18.2/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10671973
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.1.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.4
    wanted: 0.73.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Platforms

Both iOS and Android

Versions

Description

onHide callback returns Date but this date seems to be invalid and casted as boolean?

Based on description of the callback:

  • Called when the underlying modal finishes its' closing animation after Confirm was pressed. onHide?(date: Date): void;

I expected the same Date object as the one returned via onConfirm. However, based on logs they are different. For example:

Date on confirm: Thu Jun 25 2026 12:53:47 GMT+0200 Date on hide: true

Is it an issue or is it an expected behaviour? Thanks in advance :)

Reproducible Demo

Here is a repo with demo: https://github.com/ElviraBurchik/react-native-modal-datetime-picker-issue-on-hide

Checkout the repo, run the app via yarn ios or yarn android. You will the first screen. Press "Open DateTimePicker" and submit any date. The result will be shown on the screen:

Date on confirm: Thu Jun 25 2026 12:53:47 GMT+0200
Date on hide: true
simulator_screenshot_A9C81587-2198-417D-A040-4A97147B3D42 Simulator Screenshot - iPhone 14 Pro - 2024-02-23 at 12 56 33
Cosmin-Madalin commented 1 week ago

@ElviraBurchik This is the correct signature: onHide?(didPressConfirm: boolean, currentDate?: Date): void;