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
21.89k stars 1.69k forks source link

iOS - Picker does Not Resize Automatically After Selection #19295

Open Quaybe opened 7 months ago

Quaybe commented 7 months ago

Description

With the Picker in iOS, the picker does not resize automatically after selection. If you select an item that is longer than the original value of the Picker box, it is cut off:

iOS: image

Expectation: The Picker box should resize accordingly to display the longer string. This is the behavior in Windows and Android, this issue only applies to iOS. Have not tested Mac.

Android: image

Windows: image

Steps to Reproduce

  1. Create new .NET MAUI app
  2. Add Picker anywhere on screen in XAML
  3. Set Title to a short string such as "test"
  4. Add items to Picker with longer strings such as "long string test". Picker XAML example:
<Picker x:Name="picker" Grid.Column="1" VerticalOptions="Center" HorizontalOptions="Center" HorizontalTextAlignment="Center" Title="Short">
    <Picker.ItemsSource>
        <x:Array Type="{x:Type x:String}">
            <x:String>Short</x:String>
            <x:String>TEST</x:String>
            <x:String>ACL</x:String>
            <x:String>Long String</x:String>
            <x:String>Even Longer String</x:String>
            <x:String>Howler Monkey</x:String>
            <x:String>Japanese Macaque</x:String>
        </x:Array>
    </Picker.ItemsSource>
</Picker>
  1. Run app on iOS.
  2. Select one of the longer items in the Picker, tap "done"
  3. Notice that the Picker box was not resized to display the new, longer string.

Expectation: The Picker box should resize accordingly to display the longer string. This is the behavior in Windows and Android, this issue only applies to iOS. Have not tested Mac.

Link to public reproduction project repository

https://github.com/Quaybe/iOS-Picker-Bug

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17

Did you find any workaround?

Disable and enable the Picker every time the selection is changed, and it is forced to redraw to the correct size. This is my workaround currently for iOS.

Relevant log output

No response

ghost commented 7 months 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.

XamlTest commented 6 months ago

Verified this on Visual Studio Enterprise 17.9.0 Preview 2(8.0.3). Repro on iOS 17.0, not repro on Windows 11 and Android 14.0-API34 with below Project: iOSPickerBug.zip

kubaflo commented 5 months ago

@PureWeen @Quaybe a possible fix here :) https://github.com/dotnet/maui/pull/20207