Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Controls/src/Core/FlyoutPage/FlyoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ void OnWindowChanged(object sender, EventArgs e)
void OnMainDisplayInfoChanged(object sender, DisplayInfoChangedEventArgs e)
{
Handler?.UpdateValue(nameof(FlyoutBehavior));

#if ANDROID || WINDOWS
// Trigger toolbar re-evaluation on orientation change. iOS handles this natively
// via PhoneFlyoutPageRenderer.ViewWillTransitionToSize().
OnPropertyChanged(nameof(FlyoutLayoutBehavior));
#endif
}

IView IFlyoutView.Flyout => this.Flyout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ void OnPagePropertyChanged(object sender, System.ComponentModel.PropertyChangedE
NavigationPage.BarTextColorProperty) ||
e.IsOneOf(
PlatformConfiguration.WindowsSpecific.Page.ToolbarDynamicOverflowEnabledProperty,
PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty))
PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty) ||
e.Is(FlyoutPage.FlyoutLayoutBehaviorProperty))
{
ApplyChanges(_currentNavigationPage);
}
Expand Down
64 changes: 64 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24468.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 24468, "FlyoutPage toolbar button not updating on orientation change on Android and Windows",
PlatformAffected.Android | PlatformAffected.UWP)]
public class Issue24468 : TestFlyoutPage
{
private Label _eventLabel;
private Label _countLabel;
private int _callCount = 0;

protected override void Init()
{
Title = "Issue 24468";

_eventLabel = new Label
{
Text = "ShouldShowToolbarButton is not called",
AutomationId = "EventLabel"
};

_countLabel = new Label
{
Text = "0",
AutomationId = "CountLabel"
};

Flyout = new ContentPage
{
Title = "Menu",
Content = new Label { Text = "Flyout Menu" }
};

Detail = new NavigationPage(new ContentPage
{
Title = "Detail",
Content = new StackLayout
{
Children =
{
new Label { Text = "Rotate device to test toolbar button updates" },
_eventLabel,
_countLabel
}
},
AutomationId = "ContentPage"
});

FlyoutLayoutBehavior = FlyoutLayoutBehavior.SplitOnLandscape;
}

public override bool ShouldShowToolbarButton()
{
_callCount++;
var shouldShow = base.ShouldShowToolbarButton();

if (_callCount > 1)
{
_eventLabel.Text = "ShouldShowToolbarButton called";
_countLabel.Text = _callCount.ToString();
}

return shouldShow;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#if ANDROID || IOS //The test fails on Windows and MacCatalyst because the SetOrientation method, which is intended to change the device orientation, is only supported on mobile platforms iOS and Android.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue24468 : _IssuesUITest
{
public Issue24468(TestDevice device) : base(device)
{
}

public override string Issue => "FlyoutPage toolbar button not updating on orientation change on Android and Windows";
[Test]
[Category(UITestCategories.Navigation)]
public void FlyoutPageToolbarButtonUpdatesOnOrientationChange()
{
App.SetOrientationLandscape();
App.WaitForElement("ContentPage");

try
{
App.WaitForElement("EventLabel");
var eventText = App.FindElement("EventLabel").GetText();
Assert.That(eventText, Is.EqualTo("ShouldShowToolbarButton called"));

var callCount = int.Parse(App.FindElement("CountLabel").GetText() ?? "0");
Assert.That(callCount, Is.GreaterThan(1).And.LessThan(5),
$"Expected call count between 2-4, but got {callCount}. Method should not be called excessively.");
}
finally
{
App.SetOrientationPortrait();
}
}
}
#endif
Loading