Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Fixes 7992 Changes UWP DatePicker to show the picker flyout on DatePickerFocus() #8056

Merged
merged 15 commits into from
Jan 11, 2020

Conversation

bmacombe
Copy link
Contributor

@bmacombe bmacombe commented Oct 17, 2019

Description of Change

Modifies the UWP DatePickerRenderer to open a DatePickerFlyout when DatePicker.Focus() is called by overriding OnElementFocusChangeRequested. This is to match the behavior on iOS and Android.

After much research I have not been able to find a way to get the default DatePicker clicked behavior to open. So to replicate that, I use a DatePickerFlyout that is opened in OnElementFocusChangeRequested. This doesn't produce the same visual effect, but provides the same functionality.

Marking this as a draft PR right now so that this approach can be validated and approved. If approved, this same change could be made to TimePicker and maybe Picker.

Issues Resolved

Fixes #7992

API Changes

None

Platforms Affected

  • UWP

Behavioral/Visual Changes

Calling DatePicker.Focus() now opens a Flyout in UWP to match iOS and Android

Before/After Screenshots

UWP DatePicker "Clicked" flyout
image

UWP DatePickerFlyout when opened by a call to XF DatePicker.Focus()
image

Testing Procedure

Issue page in Control Gallery

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

var stackLayout = new StackLayout();
Content = stackLayout;

stackLayout.Children.Add(new Label { Text = "Label to keep picker from getting initial focus" });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the label is there, why not give it some information on what this test case does exactly. What is the person coming here expecting to see, to do and when is the test succeeded? Why try to add a label like that for most of our "Issue" pages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point, I just got the issue page to a workable stage to review the method to see if it would be acceptable, so I'll do some more polishing. I'll also go update the issue page for #7986 with instructions.

// Show a picker fly out on focus to match iOS and Android behavior
var flyout = new DatePickerFlyout { Placement = FlyoutPlacementMode.Bottom, Date = Control.Date };
flyout.DatePicked += (p, e) => Control.Date = p.Date;
flyout.ShowAt(Control);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this behave when the picker is set to not visible? See for instance #5159

Copy link
Contributor Author

@bmacombe bmacombe Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick test on when it's not visible, it opens but I'm not sure the positioning is great. Seems like it will open at the root coordinate of the current screen.

image

What I'm thinking to do is if the control isn't visible use the Full placement of the flyout, which will have the picker popup fill the current screen.

image

Thoughts?

I'll also update the issue page to include both a visible and not visible control.

@bmacombe bmacombe marked this pull request as ready for review November 14, 2019 15:45
@samhouts samhouts added the p/UWP label Jan 6, 2020
@samhouts samhouts changed the base branch from master to 4.5.0 January 7, 2020 00:57
Copy link
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected and like other platforms.

@samhouts samhouts removed the request for review from hartez January 11, 2020 00:15
@samhouts samhouts assigned samhouts and unassigned hartez Jan 11, 2020
@samhouts samhouts merged commit 0faabe0 into xamarin:4.5.0 Jan 11, 2020
@samhouts samhouts added the approved Has two approvals, no pending reviews, and no changes requested label Jan 11, 2020
@bmacombe bmacombe deleted the GitHub_7992 branch January 11, 2020 02:31
tuyen-vuduc pushed a commit to NAXAM/Xamarin.Forms that referenced this pull request Jan 14, 2020
* 'master' of github.com:xamarin/Xamarin.Forms: (330 commits)
  [Android] Fix color filter usage on API29 (xamarin#9180)
  Add null check to GetIconColor (xamarin#9172)
  Apply cecil fixes to make packages 2017 compatible (xamarin#9145)
  [UWP] Attempt to resolve entry on UWP not correctly calculating the correct height when in a scroll view (xamarin#8214)
  Fixes 7992 Changes UWP DatePicker to show the picker flyout on DatePickerFocus() (xamarin#8056)
  Update bug_report.md (xamarin#8688)
  [android/ios] improve perf when not using Application.Properties (xamarin#8887)
  The great Androidx IF Def'ing of 2019 (xamarin#8898)
  Added IconColor property for managing navigation icon color (xamarin#5185)
  Add UWP display prompt (xamarin#8720)
  fix bad merge
  Fix 8743 - now using specific style in SearchBar [UWP] (xamarin#8773)
  Added the SwipeView tag to the Core Gallery samples (xamarin#8819)
  [Tizen] Shell: FlyoutBackgroundImage, FlyoutBackgroundImageAspect (xamarin#8905)
  [Core] remove array covariant cast for UWP (xamarin#9135)
  [android] remove Anticipator.cs for now (xamarin#8858)
  Update the CarouselView Position setting the CurrentItem (xamarin#7946) fixes xamarin#7924
  send remove events (xamarin#9124)
  [platform] improve perf of PropertyChangedEventArgsExtensions (xamarin#9084)
  Fix SeachBarRenderer CreateNativeControl issue (xamarin#8946)
  ...

# Conflicts:
#	Xamarin.Forms.Core/FontImageSource.cs
@samhouts samhouts added this to the 4.5.0 milestone Jan 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Has two approvals, no pending reviews, and no changes requested hacktoberfest 🍻 p/UWP t/bug 🐛
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants