--- /dev/null
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 41424, "[Android] Clicking cancel on a DatePicker does not cause it to unfocus", PlatformAffected.Android)]
+ public class Bugzilla41424 : TestContentPage
+ {
+ const string DatePicker = "DatePicker";
+
+ protected override void Init()
+ {
+ var datePicker = new DatePicker
+ {
+ AutomationId = DatePicker
+ };
+ var datePickerFocusButton = new Button
+ {
+ Text = "Click to focus DatePicker",
+ Command = new Command(() => datePicker.Focus())
+ };
+ Content = new StackLayout
+ {
+ Children =
+ {
+ datePicker,
+ datePickerFocusButton
+ }
+ };
+ }
+
+#if UITEST
+
+#if __ANDROID__
+ [Test]
+ public void DatePickerCancelShouldUnfocus()
+ {
+ RunningApp.Tap(q => q.Marked(DatePicker));
+ RunningApp.WaitForElement(q => q.Marked("Cancel"));
+
+ RunningApp.Tap(q => q.Marked("Cancel"));
+ RunningApp.WaitForElement(q => q.Marked("Click to focus DatePicker"));
+
+ RunningApp.Tap(q => q.Marked("Click to focus DatePicker"));
+ RunningApp.WaitForElement(q => q.Marked("Cancel"));
+
+ RunningApp.Tap(q => q.Marked("Cancel"));
+ }
+#endif
+
+#endif
+ }
+}
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla31806.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41078.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40998.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41424.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" />
_disposed = true;
if (_dialog != null)
{
+ _dialog.CancelEvent -= OnCancelButtonClicked;
_dialog.Hide();
_dialog.Dispose();
_dialog = null;
_dialog.Hide();
((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
+ _dialog.CancelEvent -= OnCancelButtonClicked;
_dialog = null;
}
}
view.Date = e.Date;
((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
+
+ _dialog.CancelEvent -= OnCancelButtonClicked;
_dialog = null;
}, year, month, day);
}
UpdateMinimumDate();
UpdateMaximumDate();
+
+ _dialog.CancelEvent += OnCancelButtonClicked;
_dialog.Show();
}
+ void OnCancelButtonClicked(object sender, EventArgs e)
+ {
+ Element.Unfocus();
+ }
+
void SetDate(DateTime date)
{
Control.Text = date.ToString(Element.Format);