-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Calling Focus on all Pickers running an API 28 devices no longer opens Picker #5159
Comments
@PureWeen Are you looking at this one? |
@varyamereon I've attached a quick sample based on the one you linked that works for me. Can you try it? |
@PureWeen EDIT |
Anyone found a solution to this? Currently experiencing the exact same issue when compiling against Android 28 (Pie). On devices that are 8.1 and lower (using the same APK built against Android 28), the date time pickers work. Only happens when running on an Android 9.0 device. |
I just did a bit of testing. In the start, our xaml looks like this (notice, they start off invisible):
Our code was just calling ".Focus()" on one of these elements (depending on the button you click, of course).
If I change my code to the following, the date picker input box appears (we don't want this to happen - all we want to happen is to bring up the date/time picker dialog). BUT along with the input field appearing, the date/timer picker dialog DOES appear.
|
The picker not working too, not only DatePicker. |
https://developer.android.com/about/versions/pie/android-9.0-changes-28
Pickers probably should have a ShowDialog method instead of just having to go via focus |
Facing the same issue. Any quick workarounds for this at the moment? |
I put the button I am using to activate it, and the picker itself in a grid in the same column and did: HeightRequest="1" WidthRequest="1" Margin="0" HorizontalOptions="Center" on the picker. So basically hide the picker behind the button, and it seems to work. |
Hopefully this can help somebody else. Full disclosure -- it's a hack, but it works. I was able to work around this issue with a custom picker renderer bypassing the default implementation of the For reference, take a look at the IPickerRenderer.OnClick method for the Android PickerRenderer: Here is the relevant code:
|
check if the IsEnable property is set to false then the focus() event won't work on api 28, setting it to true or removing it will fix the issue and make the datepicker focus works. |
Tried all the workarounds, some work but only once and the custom renderer is overkill for my purposes.
|
@chrisfoulds sorry it did not work for me either. The only workaround I've found is using a custom renderer (quite easy to write in fact) following these instructions |
The solution I posted above works great for me, in a product app now with 20k DAU's and no complaints so surprised you had to go down the custom renderer route. |
@chrisfoulds I am using it in a "modal page", that's maybe the issue ? |
@jonathanantoine maybe , I just checked I am using it on a standard navigation page which may make all the difference. |
So, if I have reproduced this correctly in the Gallery app, it's not so much a problem of receiving focus. That seems to still work, but the I have tried both This seems to work in all cases I have tried so far, at the time of writing the UI tests are still running. In any case, if this works, I don't really see the need to keep the I'm curious to hear any of your thoughts about this. Edit: this fix does not seem to work for Picker for some reason... |
My picker was hidden behind another view so setting the IsVisible workaround didn't work for me. This line in constructor of the Page.xaml.cs worked for me:
|
I've used the workaround from @truXton222 but now when I press backbutton on the device the datepicker dialog shown again instead of view going back :| |
@jfversluis would be great! |
closed by #7289 |
This was the only work around which works for me sadly it only works the first time. After dismissing the picker I can't seem to bring it up anymore unless I switch to another views and later come back to the view with the picker. |
@gilles-leblanc did you try the latest 4.2 version (or 4.3-pre) the fix for this should be incorporated in there? If you still find that it's not working, please open a new issue. |
Description
When using API Level 28, calling Focus on a DatePicker with Visible set to false does not show the date picker dialog.
Prior to this PR https://github.com/xamarin/Xamarin.Forms/pull/4344/files#diff-446294d29d78ca8d84e4c0ddc20bbc07L132 the Picker was opened as part of the FocusRequestedEvent. PR #4344 brought DatePicker inline with the other pickers by changing it to trigger a Click on the control which then would trigger the click listener to open the picker.
On API 28 FocusRequestedEvent is still called so there is still an opportunity to react to this. The difference on API 28 is that the Focus request fails so the Click Listener never actually fires.
Possible fix ideas
Steps to Reproduce
Expected Behavior
DatePicker dialog is shown.
Actual Behavior
Nothing happens.
Basic Information
Screenshots
n/a
Reproduction Link
Reproduction
The text was updated successfully, but these errors were encountered: