maui icon indicating copy to clipboard operation
maui copied to clipboard

[Android] Pickers reopen when the selected item is re-selected

Open mfeingol opened this issue 7 months ago • 2 comments

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

  1. Make a new MAUI project
  2. Add some pickers to the page. Having multiple ones seems to exacerbate the issue. Also having ones with only one item.
  3. Tap on the pickers and re-select the selected item
  4. 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

mfeingol avatar Jan 07 '24 18:01 mfeingol

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.

ghost avatar Jan 08 '24 15:01 ghost

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.

ghost avatar Jan 08 '24 15:01 ghost

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.

mfeingol avatar Jan 10 '24 01:01 mfeingol

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 Android

XamlTest avatar Feb 01 '24 07:02 XamlTest

@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

kubaflo avatar Feb 14 '24 14:02 kubaflo