material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[MaterialTimePicker] Control Field Focus on Open

Open jbh6gc opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. My app opens the MaterialTimePicker dialog into text input mode. When this happens the hour field is focused. Since the hour field is focused the user can't see the current value of that field. It is a little confusing for the user not to have the context of what the current value is.

Describe the solution you'd like The behavior of this scenario in the 1.6.1 version of the component is that the hour field is not focused when the dialog is first opened. This worked well for us. It looks like 72abed042f7577a6e24219742d0a5ac860adcb56 which was added in 1.7.0-alpha02 changed this behavior so that it focuses on open. It seems from #1511 that the intent was to focus the field when switching from clock mode to text mode so I was thinking it might make sense to only focus a field if it has been focused by the user already in any mode, but if opening directly in text input mode it would not focus anything right away.

Describe alternatives you've considered I tried to just stick with version 1.6.1 for my app which has the desired behavior, but #2788 is big enough that we needed to upgrade to 1.7.0 to get the fix for it. I did not see any attributes or settings on the builder or picker itself that would flex this behavior for us either.

Additional context Here's a screenshot of what the Time Picker looks like when we first open it in text input mode: Screenshot_20220726-100208

jbh6gc avatar Jul 26 '22 15:07 jbh6gc

Let's probably add and option to opt in/out this behavior?

drchen avatar Jul 26 '22 17:07 drchen

Yeah, being able to opt in/out would definitely work for us. Thanks for the quick response!

jbh6gc avatar Jul 26 '22 17:07 jbh6gc

I get invalid reports from users that while they edit time the hour is always erasing (this is not true but for user it is not transparent). Will this optional flag be introduced or i should explain to users that this is normal behavior?

Shusek avatar Oct 03 '22 07:10 Shusek

Hi, we reviewed this issue with our designers and made a change, now the hour/minute edit texts are pre-filled and the text gets automatically replaced once the user starts typing (so no extra interaction required). See https://github.com/material-components/material-components-android/commit/56ea071320719b438ba2e0d40ab74e38dc474b07.

paulfthomas avatar Oct 05 '22 14:10 paulfthomas