dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

[regression/7.0.96] Picker is empty on mac catalyst #18015

Open singhwong opened 1 year ago

singhwong commented 1 year ago

Description

Picker is empty on mac catalyst, no list is displayed, just a pop-up window.

Steps to Reproduce

  1. Create a file>New .Net MAUI App
  2. Add sample code to MainPage
    <Picker x:Name="picker"
        Title="Select a monkey">
    <Picker.ItemsSource>
    <x:Array Type="{x:Type x:String}">
      <x:String>Baboon</x:String>
      <x:String>Capuchin Monkey</x:String>
      <x:String>Blue Monkey</x:String>
      <x:String>Squirrel Monkey</x:String>
      <x:String>Golden Lion Tamarin</x:String>
      <x:String>Howler Monkey</x:String>
      <x:String>Japanese Macaque</x:String>
    </x:Array>
    </Picker.ItemsSource>
    </Picker>
  3. Click the Picker 截屏2023-10-13 下午11 38 43

Link to public reproduction project repository

No response

Version with bug

7.0.96

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOS Sonoma 14.0

Did you find any workaround?

No response

Relevant log output

No response

samhouts commented 1 year ago

Thank you for the report! You said that this used to work on an unknown version. Was this working in .NET 7?

ghost commented 1 year ago

Hi @singhwong. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. 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.

singhwong commented 1 year ago

This issue occurs when using MacOS Sonoma 14 + .net7 7.0.400 + maui 7.0.96 or MacOS Sonoma 14 + .net8 8.0.100-rc.2.23502.2 + maui 8.0.0-rc.2.9373, and what I can be sure of is that when using the previous version of maui (maui 7.0.92) + the previous version of macOS (not sonoma), working properly.

drasticactions commented 1 year ago

As far as I can tell This will be happening regardless of the version of MAUI being used, going by how the underlying control is written:

https://github.com/dotnet/maui/blob/main/src/Core/src/Handlers/Picker/PickerHandler.iOS.cs#L41

The Maui Picker is a wrapper around a UITextField that fires a UIAlert to show a picker. That code doesn't work on Sonoma, it'll just show the alert. There's probably gonna need to be some rethinking around how that control works.

e.

https://github.com/dotnet/maui/blob/net7.0/src/Core/src/Handlers/Picker/PickerHandler.iOS.cs#L73C3-L79

So I believe the way this worked was by using UITextView. When you tapped it, it will fire an event on edit to create a UIAlertController with an ActionSheet style, and hijack it by replacing its underlying view with a UIPickerView instead. My guess is that, while possible since the View is publicly exposed, it's against the spirit of the control and that broke with Sonoma and/or Xcode so it actually shows the Alert now. @rolfbjarne would you have any ideas for this? It seems like how this is written was kinda fragile.

rolfbjarne commented 1 year ago

@rolfbjarne would you have any ideas for this? It seems like how this is written was kinda fragile.

Why was a UIAlertController needed in the first place? What's the test code supposed to do?

samhouts commented 1 year ago

@rmarinho Do you remember why we had to write it this way?

TiberiusDRAIG commented 1 year ago

Hi, this is a critical issue for us going into .NET 8 - our app makes use of pickers, and they are simply not functional in this state. Additionally, the current implementation of Picker on Catalyst does not work at all when using the Desktop idiom, and actually causes the entire app to crash.

As a core control in MAUI, I believe this should be considered and prioritised as a major issue since it will block customer releases - in our case, we just can't release our app at all, and the bugs that remain in .NET 7 mean that is not an option for us either.

@samhouts Please reconsider removing this from the .NET 8 GA milestone!

Almis90 commented 1 year ago

What does this mean? will be fixed before .NET 8 GA release?

ghost commented 1 year ago

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.

cdavidyoung commented 1 year ago

I have noticed with my app on MacCatalyst that the menu bars and DisplayActionSheet have stopped working since the latest updates. I was looking through the maui-samples for something to demonstrate this and found that the pickers are also not working. I assume this is related but perhaps it is not.

TiberiusDRAIG commented 1 year ago

Just throwing it out there in case it helps anyone: we've quickly knocked together a simple picker-type control using the popup stuff from the MAUI Community Toolkit and a CollectionView being invoked from a read only Entry with a TapGesture - it's rudimentary, but, it gets the job done within our context and it didn't take long to write.

For what it's worth, it's probably worth looking at something like that if you're in a jam; after doing way too much reading, I'd guess the UIKit Picker's compatibility with Catalyst and the surprising amount of complication around what you can/cannot do entered into this at some point. The control is a bit rubbish on desktop even without any .NET involved (horrible with a mouse), and it's entirely unsupported by Apple on the desktop idiom too just to add to its lameness, so now I'm not panicking and have an easy alternative I'm realising it's not a huge loss in the end.

EDIT: All this being said, this is now a bit of a gap - maybe something for MCT?

davidortinau commented 11 months ago

Confirmed in 8.0.4-nightly.9742

davidortinau commented 9 months ago

I found that the Picker works on Mac Catalyst so long as I don't use the Title property.

<Picker x:Name="AppearancePicker"
    Title="Appearance"
    BackgroundColor="Transparent">
    <Picker.ItemsSource>
        <x:Array Type="{x:Type x:String}">
            <x:String>Unspecified</x:String>
            <x:String>Dark</x:String>
            <x:String>Light</x:String>
        </x:Array>
    </Picker.ItemsSource>
</Picker>
Screenshot 2024-02-26 at 7 51 14 PM

Removed Title:

<Picker x:Name="AppearancePicker"
    BackgroundColor="Transparent">
    <Picker.ItemsSource>
        <x:Array Type="{x:Type x:String}">
            <x:String>Unspecified</x:String>
            <x:String>Dark</x:String>
            <x:String>Light</x:String>
        </x:Array>
    </Picker.ItemsSource>
</Picker>
Screenshot 2024-02-26 at 7 50 11 PM
Axemasta commented 8 months ago

@davidortinau thanks for the heads up about removing the title, I've put an OnPlatform to bodge my way around this for mac:

<Picker
    ItemDisplayBinding="{Binding Name}"
    ItemsSource="{Binding ServiceConnections}"
    SelectedItem="{Binding SelectedConnection}"
    TextColor="{StaticResource White}"
    TitleColor="LightGray"
    Title="{OnPlatform iOS='Select an environment...',
                       Android='Select an environment...',
                       WinUI='Select an environment...'}" />

I'm happy there is a workaround & know theres still alot todo for maui but I hope this gets fixed soon because its really impacts the use case of mac catalyst if the basic controls don't actually work 😔

Bruno2049 commented 8 months ago

In version 8.0.201, the Picker stop working again, even without the Title property set.

malsabi commented 5 months ago

This is still happening in .NET 8 RC5

Zhanglirong-Winnie commented 3 months ago

This issue has been verified using Visual Studio For MAC 17.6.14(build413)(8.0.80 & 8.0.3 & 7.0.101). Can repro on MacCatalyst platform. Verified working fine on 7.0.96.

chrisntr commented 2 months ago

I'm still seeing this behaviour in .NET 9 MAUI builds too