maui
maui copied to clipboard
[Android] Pickers reopen when the selected item is re-selected
Description
Pickers reopen after selecting an item that's already selected. Easy to observe with a picker with only one item.
I suspect the problem comes from the code that reopens the picker on focus change: https://github.com/dotnet/maui/blob/main/src/Core/src/Handlers/Picker/PickerHandler.Android.cs#L94
Steps to Reproduce
- Make a new MAUI project
- Add some pickers to the page. Having multiple ones seems to exacerbate the issue. Also having ones with only one item.
- Tap on the pickers and re-select the selected item
- Observe the pickers reopen after selection
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
A workaround is to do this:
class CustomPicker : Picker
{
public CustomPicker()
{
// Maui: work around https://github.com/dotnet/maui/issues/15394
this.Focused += (s, e) => this.Unfocus();
}
}
Relevant log output
No response
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
Hi @mfeingol. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Added repro: https://github.com/mfeingol/repros/tree/master/PickerFocusRepro
Turns out the issue is with Pickers inside ViewCells. The workaround is to not do that. I was using a TableView and I've reverted to a manual layout.
Verified this on Visual Studio Enterprise 17.9.0 Preview 5(8.0.3). Repro on Android 14.0-API34 with below Project:
PickerFocusRepro.zip
@mfeingol Hi, I've just discovered something interesting: this bug happens for TableView, CollectionView, and ListView only if they are not wrapped inside any layout, but are the direct child of a ContentPage. When the list is inside eg. Grid everything works just fine