Bug 58779 - [MacOS] DisplayActionSheet on MacOS needs scroll bars if list is long
Summary: [MacOS] DisplayActionSheet on MacOS needs scroll bars if list is long
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Mac ()
Version: 2.3.5
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2017-08-15 16:41 UTC by RogerH
Modified: 2017-10-10 19:32 UTC (History)
3 users (show)

Tags: fr
Is this bug a regression?: ---
Last known good build:


Attachments
Screen shot of list going off the screen (56.59 KB, image/png)
2017-08-15 16:41 UTC, RogerH
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description RogerH 2017-08-15 16:41:34 UTC
Created attachment 24197 [details]
Screen shot of list going off the screen

I am using Xamarin Forms DisplayActionSheet with a list of 15 items that the user can pick from.
On iOS, the Xamarin Forms GUI presents the DisplayActionSheet with a scrollable list of items.
On MacOS the Xamarin Forms code opens a window with no scrollable list. The popup window is so large it goes off the bottom of the Mac desktop and you cannot see the Cancel button and you cannot scroll the list so cannot select from all 15 items.


The implementation is a NSAlert in Xamarin.Forms/Xamarin.Forms.Platform.MacOS/Platform.cs uses
     static NSView GetExtraButton(ActionSheetArguments arguments) {}
to create a view containing all the buttons. This needs to be expanded to include a scrolling view


Attached is a screen shot that shows the problem.
Comment 1 RogerH 2017-08-15 16:42:40 UTC
Xamarin Forms is 2.3.5.256-pre6
Comment 2 RogerH 2017-08-15 16:50:07 UTC
I have a sample project too, but when zipped it is more than the 8Meg size. Let me know if I can upload this somewhere.
But to help you out here is my code that shows the problem


//
// when the user clicks on CLICK ME, open a DisplayActionSheet with 15 items
//
using System;

using Xamarin.Forms;

namespace ActionSheetBug
{
	public class App : Application
	{
		public App ()
		{
		    Button button = new Button
            {
                Text = "Click Me!",
                Font = Font.SystemFontOfSize(NamedSize.Large),
                BorderWidth = 1,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            
			// The root page of your application
			var content = new ContentPage {
				Title = "ActionSheetBug",
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Center,
					Children = {
						new Label {
							HorizontalTextAlignment = TextAlignment.Center,
							Text = "Tap on button to show DisplayActionSheet"
						},
						button
							
					}
				}
			};
			
			button.Clicked += (sender, e) => {
				String[] string_array = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"};
				content.DisplayActionSheet("title","cancel","destruction",string_array);
			};

			MainPage = new NavigationPage (content);
		}

	}
}
Comment 3 RogerH 2017-08-19 06:54:57 UTC
I have implemented a fix in my local Xamarin Forms branch


In the file Xamarin.Forms/Xamarin.Forms.Platform.MacOS/Platform.cs

Change this
-----------

	var alert = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Destruction, null, "");
		if (arguments.Buttons != null)
		{
			alert.AccessoryView = GetExtraButton(arguments);
			alert.Layout();
		}




To this
-------

	var alert = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Destruction, null, "");
	if (arguments.Buttons != null)
		{
		// Place ExtraButtons inside a NSScrollView
		NSView extrabuttons = GetExtraButton(arguments);
		NSScrollView scroller = new NSScrollView();
		scroller.Frame = new RectangleF(0, 0, 300, 250);
		scroller.DocumentView = extrabuttons;
		alert.AccessoryView = scroller;
		alert.Layout();
	}
Comment 4 RogerH 2017-08-22 16:28:18 UTC
have done a Pull Request on GitHub for the fix and a test case.
Comment 5 RogerH 2017-08-30 08:48:21 UTC
my PR fixes the problem of the list going off the screen (for long lists)

There is an additional bug not in my PR. The list is in the wrong order compared with Xamarin.Droid and Xamarin.iOS
Eg 

iOS/Android

+--------+
+ TITLE  +
+--------+
+ Item 1 +
+--------+
+ Item 2 +
+--------+
+ Item 3 +
+--------+
+ CANCEL +
+--------+


Mac OS
+--------+
+ TITLE  +
+--------+
+ Item 3 +
+--------+
+ Item 2 +
+--------+
+ Item 1 +
+--------+
+ CANCEL +
+--------+
Comment 6 RogerH 2017-09-01 16:05:24 UTC
My Pull Request has been merged into Xamarin Forms on GitHub.
The second issue where the list is in the wrong order will be carried to another PR.
Comment 7 Samantha Houts [MSFT] 2017-10-10 19:32:03 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1109