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

Datepicker is not opened when we call Datepicker.Focus() in UWP #7992

Closed
Balasubramanian93 opened this issue Oct 14, 2019 · 9 comments
Closed
Labels
e/2 🕑 2 in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛

Comments

@Balasubramanian93
Copy link

Balasubramanian93 commented Oct 14, 2019

Description

Datepicker is not opened when we call Datepicker.Focus() in UWP. I have tried to open the date picker dialog on a button click by calling Datepicket.Focust() method. Note: This is working as expected in Android and iOS.

Steps to Reproduce

  1. Run the attached sample.
  2. Click the button "Button"

Expected Behavior

Datepicker dialog should be opened.

Actual Behavior

Datepicker dialog is not opened

Basic Information

  • Version with issue: 4.2.0.709249
  • Last known good version:
  • IDE: VS 2019
  • Platform Target Frameworks:
    • UWP: 177 63
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices: Desktop
    DatePickerBlankApp.zip
@Balasubramanian93 Balasubramanian93 added s/unverified New report that has yet to be verified t/bug 🐛 labels Oct 14, 2019
@jfversluis
Copy link
Member

jfversluis commented Oct 14, 2019

Confirmed that this is happening. As discussed in #5159, ultimately we want to move away from doing this with focus, but for the time being that is the way to go.

Also, don't forget to check the regular Picker and TimePicker

@jfversluis jfversluis added p/UWP e/2 🕑 2 and removed s/unverified New report that has yet to be verified labels Oct 14, 2019
@Balasubramanian93
Copy link
Author

Hi @jfversluis , Can this issue be addressed in the next pre release atleast for UWP?

@jfversluis
Copy link
Member

@Balasubramanian93, I wish I could say yes, but the truth is that at this time I'm no sure when work on this will be done and when it will be included. Whenever the status is updated you will see it here.

@bmacombe
Copy link
Contributor

I've got an idea on how to address this, working up something now and will post a draft PR for the DatePicker only to get some feedback. Hopefully yet today.

@jfversluis
Copy link
Member

Let us know how it goes @bmacombe!

@bmacombe
Copy link
Contributor

Ran into some complications...still working on it. UWP handles these flyouts different then I was expecting based on wpf and silver light. I totally agree having a show method in xf vs on focus would be great!

@bmacombe
Copy link
Contributor

@jfversluis Quick preview of what I'm thinking.

In the Renderer override OnElementFocusChangeRequested, since this will only be called when Focus() is called on the picker. This then ignores all the focus events from the native uwp control. Which will keep the flyout from opening on things like tabbing through controls, etc. So it will only display on a call to the XF Focus method. Pretty much like if the Show/Open was implemented.

I wanted to avoid the behavior change discussions on this bugzilla issue I found.

https://xamarin.github.io/bugzilla-archives/52/52266/bug.html

internal override void OnElementFocusChangeRequested(object sender, VisualElement.FocusRequestArgs args)
{
	base.OnElementFocusChangeRequested(sender, args);

	if (Control.ContextFlyout == null)
	{
		var flyout = new DatePickerFlyout();
		flyout.Placement = FlyoutPlacementMode.Bottom;
		Control.ContextFlyout = flyout;
	}
	Control.ContextFlyout.ShowAt(Control);
}

What I have left to figure out is how to make the manual flyout match the same appearance as the flyout when you click on the control. The default opens on top of the control, centered vertically and with the same width.

image

Right now I've only figured out how to set the placement, which all the options don't match the default appearance Now that I have the basic behavior sorted out, I'll start digging into matching the visual appearance.

image

@bmacombe
Copy link
Contributor

Of course the above method, doesn't actually update the original datepicker value. I'm sure I could bind it...I'm really struggling to find a way to activate the UWP DatePicker Click handling.

@bmacombe
Copy link
Contributor

@jfversluis I've opened a draft PR for review my approach to this issue, a review at your convenience
would be greatly appreciated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e/2 🕑 2 in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛
Projects
None yet
Development

No branches or pull requests

4 participants