Skip to content

Commit

Permalink
fix(flyout): open flyout on tap
Browse files Browse the repository at this point in the history
(cherry picked from commit e81f61d)
  • Loading branch information
ramezgerges authored and mergify[bot] committed Aug 9, 2023
1 parent cb89661 commit 78ba0bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#pragma warning disable 168 // for cleanup imported member

#if !WINDOWS_UWP

using System.Linq;
using System.Threading.Tasks;
using Windows.Foundation;
Expand Down Expand Up @@ -184,29 +182,18 @@ public async Task CanOpenFlyoutByTapping()
{
var cp = new CalendarDatePicker();

var rootPanel = XamlReader.Load(
"<Grid xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' " +
" Width='400' Height='400' VerticalAlignment='Top' HorizontalAlignment='Left' Background='Navy'/>")
as Grid;

WindowHelper.WindowContent = rootPanel;

rootPanel!.Children.Append(cp);
WindowHelper.WindowContent = cp;

await WindowHelper.WaitForLoaded(cp);
await WindowHelper.WaitForIdle();

var root = GetTemplateChild(cp, "Root") as Grid;
var dateText = GetTemplateChild(cp, "DateText") as TextBlock;

Assert.IsNotNull(root);
Assert.IsNotNull(dateText);

var root = GetTemplateChild(cp, "Root") as Grid;
flyout = FlyoutBase.GetAttachedFlyout(root);
Assert.IsNotNull(flyout);

TestServices.InputHelper.Tap(dateText);
await WindowHelper.WaitForIdle();

Assert.IsTrue(flyout.IsOpen);
}
finally
{
Expand Down Expand Up @@ -319,7 +306,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("https://github.com/unoplatform/uno/issues/10165")]
[RunsOnUIThread]
public async Task CanCloseFlyoutBySelectingADate()
{
TestCleanupWrapper cleanup;
Expand All @@ -331,7 +318,7 @@ public async Task CanCloseFlyoutBySelectingADate()
CalendarView calendarView = null;
CalendarDatePickerHelper helper = new CalendarDatePickerHelper();
await helper.PrepareLoadedEvent();
Windows.UI.Xaml.Controls.CalendarDatePicker cp = await helper.GetCalendarDatePicker();
CalendarDatePicker cp = await helper.GetCalendarDatePicker();

rootPanel = await CreateTestResources();

Expand Down Expand Up @@ -1000,4 +987,3 @@ await RunOnUIThread(() =>
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public CalendarDatePicker()
m_shouldPerformActions = false;
m_isSelectedDatesChangingInternally = false;

Tapped += OnTap;

PrepareState();
}

Expand Down Expand Up @@ -696,6 +698,18 @@ protected override void OnKeyDown(KeyRoutedEventArgs pArgs)
return;
}

protected void OnTap(object sender, TappedRoutedEventArgs args)
{
if (!IsEnabled || args.Handled)
{
return;
}

IsCalendarOpen = true;
args.Handled = true;
UpdateVisualState();
}

protected override void OnPointerPressed(PointerRoutedEventArgs pArgs)
{
//CalendarDatePickerGenerated.OnPointerPressed(pArgs);
Expand Down

0 comments on commit 78ba0bb

Please sign in to comment.