Repository navigation
Unexpected showDatePicker behavior when changing year #81547
Copy link
Copy link
Closed
Labels
f: date/time pickerDate or time picker widgetsDate or time picker widgetsfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
It's not clear if this is a bug or intended behavior, but at any rate the Flutter Material date picker has a behavior that differs from that of the native Android date picker in such a way that is likely to cause users accustomed to the native behavior to select the wrong date in a Flutter app.
Steps to Reproduce
- Open a date picker with
showDatePickerwithinitialDate: DateTime(2021, 4, 30) - Tap the year control and select 2015 (or any other year)
Expected results:
4/30/2015 ought to be the newly selected date i.e. the month/day in the newly selected year that corresponds to that of the previously selected date (or closest available).
Actual results:
The date picker displays April in 2015, but 4/30/2021 remains the selected date. If the user taps OK at this point intending to select 4/30/2015 then they will actually select 4/30/2021.
RPReplay_Final1619795575.MP4
Logs
[✓] Flutter (Channel stable, 2.0.3, on Mac OS X 10.15.7 19H1030 darwin-x64, locale en-US)
• Flutter version 2.0.3 at /Users/jonathan.joelson/repos/flutter
• Framework revision 4d7946a68d (6 weeks ago), 2021-03-18 17:24:33 -0700
• Engine revision 3459eb2436
• Dart version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/jonathan.joelson/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.55.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.21.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
f: date/time pickerDate or time picker widgetsDate or time picker widgetsfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Activity
HansMuller commentedon Apr 30, 2021
CC @darrenaustin
jjoelson commentedon Aug 11, 2021
@HansMuller @darrenaustin Having shipped this to real users, I can confirm that this is extremely confusing in practice. We have lots of users entering the wrong date by mistake.
I would consider this a dire usability issue in an extremely popular component. I can see that others have reported this issue and I would be surprised if there is any Flutter app that uses this component for inputting, say, a user's birthday that isn't having many users select the wrong date by mistake.
It turns out that it is an extremely common user behavior to select the month and day first, and then change the year. In the native Android date picker this works as expected, but in Flutter the user will select the wrong year.
To drive home how big a problem this is, we
are considering switchinghave switched to the Cupertino date picker even for our Android users.TahaTesser commentedon Oct 1, 2021
Hi @jjoelson
Thanks for filing the issue
minimal code sample
stablemasterCheck
flutter doctor -voutputs for each channel belowflutter doctor -v
✅: No Issue ❗️: Issue reproduced
TahaTesser commentedon Oct 13, 2021
@jjoelson
I just tested this behavior, if you set the initial date and go to 2015, it still returns
4/30/2021(which matches Flutter behavior). if you omit the initial date, "okay" is not active, forcing the user to choose a date when scrolling back to 2015minimal code sample
Screen.Recording.2021-10-13.at.2.02.34.PM.mov
It returns
1619740800000which isApril 30, 2021jjoelson commentedon Oct 13, 2021
Hi @TahaTesser, thanks for looking into this!
I am not an Android developer or user, so I'm not terribly surprised to find that my information about the native material picker is incorrect 😅. When I created this issue, I created a simple HTML date input, assuming that Chrome uses the native material date picker:
Android.-.Date.Picker.mov
So with the native picker's behavior acknowledged, we still have a major usability issue on our hands here, even if it's not exclusive to Flutter's Material implementation.
If you go to the Material date picker documentation and scroll down to the video captioned with "Tapping the year menu accesses the year picker. Scrolling vertically navigates across years", you'll see that changing the year from 2018 to 2016 also changes the selected date: direct video link
Obviously that video is just a mockup, but it seems possible to me that the intended design here is for the date to change when the year changes. Is it possible that in replicating the native Material date picker component, Flutter has also replicated a bug in that component?
This is a smaller issue, but Flutter's Material date picker doesn't allow you to omit
initialDatein order to disable the "OK" button as far as I can tell.TahaTesser commentedon Oct 13, 2021
@jjoelson
Thanks for the quick response, this really helps.
TahaTesser commentedon Nov 11, 2021
While the design video clearly shows that is not working as expected but even Android 12 doesn't have match the behavior. This is a breaking change, most people will compare the flutter calendar with the native android calendar, and might think this is odd. So I can't move forward with this for now
cc: @darrenaustin
vitalnik commentedon May 31, 2022
Still experiencing this issue in May 2022. Are there any updates/fixes?
Fix material date picker behavior when changing year (#130486)
Fix material date picker behavior when changing year (flutter#130486)
Fix material date picker behavior when changing year (flutter#130486)
github-actions commentedon Aug 7, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.