Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picker behavior on Mac Catalyst #10208

Open
mike3sullivan opened this issue Sep 19, 2022 · 4 comments
Open

Picker behavior on Mac Catalyst #10208

mike3sullivan opened this issue Sep 19, 2022 · 4 comments
Labels
area-controls-picker Picker platform/macOS 🍏 macOS / Mac Catalyst s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@mike3sullivan
Copy link

mike3sullivan commented Sep 19, 2022

Description

I am not sure why the default behavior of the Picker control on Mac Catalyst is considered acceptable -- it 'functions' but from a desktop app perspective it is unacceptable.

Opening the picker produces a modal scrollable list, which isn't ideal as it won't disappear until the Done button is clicked or you click away into the app. That alone wouldn't be so bad if the SelectedItem didn't follow the scrolling, sending the value to the app even though the user has not 'selected' the item by clicking the item, clicking Done or clicking away. [edit to clarify: if you lift your finger from the mouse to reposition so you can scroll further down the list, the SelectedItem will trigger]

This makes triggering any app action on a change to the SelectedItem impossible (false triggering as they scroll through the list).

Repo demonstrates that the label is updated with the SelectedItem value though data binding, as you scroll through the items.
Screen Shot 2022-09-19 at 3 30 38 PM

Steps to Reproduce

in the repo project, open the picker on MacOS, scroll through the values. If you pause briefly, the Label on the right side updates showing that the SelectedItem value has changed through data binding.

MacOS Monterey 12.6,
dotnet version 6.0.401

Link to public reproduction project repository

https://github.com/mike3sullivan/MauiPickerMac

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

MacOS Monterey 12.6

Did you find any workaround?

No response

Relevant log output

No response

@mike3sullivan mike3sullivan added the t/bug Something isn't working label Sep 19, 2022
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Sep 20, 2022
@rachelkang rachelkang added this to the Backlog milestone Sep 23, 2022
@ghost
Copy link

ghost commented Sep 23, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mike3sullivan
Copy link
Author

mike3sullivan commented Oct 9, 2022

After digging into this a bit, it looks like this is the normal behaviour of the SwiftUI Picker control -- it triggers on a selected item when pausing the scroll and lifting your finger from the mouse for a second.

edit: after trying to use the control as-is for a while, I understand why someone chose to make the popup modal -- it is a major pain to have it trigger something if you pause while scrolling. The bug is that the trigger is passed through to the underlying event handler even though the modal popup remains open -- it should only be trigger the event when it closes.

I would appreciate it if someone knew of a workaround for this as it has become the one Mac desktop issue I can't find a workaround for as yet.

@jinxinjuan jinxinjuan added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels May 23, 2023
@jinxinjuan
Copy link
Collaborator

Verified this issue with 17.6 Preview (17.6 build 1539). Can repro this issue with sample project. MauiPickerMac

@oliver-ec
Copy link

oliver-ec commented Dec 11, 2023

This was an issue back in Xamarin.Forms with iOS and at least in Xamarin there is an easy fix from the managed code:
https://blog.pieeatingninjas.be/2017/07/06/bind-to-xamarin-picker-but-only-update-value-after-hitting-done-on-ios/

And actually I found something to fix this for you, that Microsoft shared already for iOS
https://learn.microsoft.com/en-us/dotnet/maui/ios/platform-specifics/picker-selection?view=net-maui-8.0

<ContentPage ...
             xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls">
    <StackLayout Margin="20">
        <Picker ... Title="Select a monkey" ios:Picker.UpdateMode="WhenFinished">
          ...
        </Picker>
        ...
    </StackLayout>
</ContentPage>

If you look for mac specific namespace, they don't have the same Picker.UpdateMode exposed yet.

BUT, it worked for me on mac catalyst with the above implementation (using iOS specific namespace).
The fact that iOS specific flags change the behaviour on Mac Catalyst Picker probably should be considered a bug in a perfect world, but solves this particular issue.

If you want to dig deeper, but not really platform specific code deep, there's a hint here:

https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/Picker/Picker.iOS.cs

And also note that under the Picker folder there are platform specific implementations like:
Picker.Android.cs
Picker.WIndows.cs
Picker.iOS.cs

where Picker.Mac doesn't exist. So I think mac catalyst just uses the iOS picker - and that makes sense as MacCatalyst is essentially an iOS app running on Mac. So maybe the fact that you need to invoke iOS specific namespace to alter MacCatalyst behaviour is fine for the most part.

If you need separation between Mac/iOS then you can do conditional compilation like suggested here:
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/customize?view=net-maui-8.0

@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-picker Picker platform/macOS 🍏 macOS / Mac Catalyst s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants