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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27732.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using Microsoft.Maui.Controls.Shapes;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 27732, "[Windows] View Position Shifts When Shadows Are Dynamically Removed or Resized", PlatformAffected.UWP)]
public class Issue27732 : TestContentPage
{
Border borderShadow;
Image imageShadow;
Label labelShadow;
Button shadowButton;
bool _shadow = false;

protected override void Init()
{
Title = "Issue27732";
borderShadow = new Border
{
AutomationId = "BorderShadow",
StrokeShape = new RoundRectangle { CornerRadius = 24 },
Background = Colors.Red,
WidthRequest = 80
};

imageShadow = new Image
{
AutomationId = "ImageShadow",
Aspect = Aspect.AspectFit,
Source = "oasis.jpg",
WidthRequest = 80
};

labelShadow = new Label
{
AutomationId = "LabelShadow",
Text = "Label",
FontSize = 18,
WidthRequest = 80
};

shadowButton = new Button
{
AutomationId = "ToggleShadowButton",
Text = "Add Shadow",
HorizontalOptions = LayoutOptions.Start
};
shadowButton.Clicked += OnShadowClicked;

Content = new StackLayout
{
Margin = new Thickness(0, 40),
HorizontalOptions = LayoutOptions.Center,
Spacing = 20,
Children =
{
new HorizontalStackLayout
{
HorizontalOptions = LayoutOptions.Center,
Spacing = 10,
Children = { borderShadow, imageShadow, labelShadow }
},
new HorizontalStackLayout
{
Spacing = 10,
Children =
{
new Label
{
Text = "Toggle Shadow Button:",
FontSize = 15,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Start
},
shadowButton
}
}
}
};
}

void OnShadowClicked(object sender, EventArgs e)
{
if (_shadow)
{
shadowButton.Text = "Add Shadow";
borderShadow.Shadow = imageShadow.Shadow = labelShadow.Shadow = null;
_shadow = false;
}
else
{
shadowButton.Text = "Remove Shadow";

var newShadow = new Shadow
{
Brush = Brush.Black,
Offset = new Point(4, 4),
Radius = 10,
Opacity = 0.5f
};

borderShadow.Shadow = imageShadow.Shadow = labelShadow.Shadow = newShadow;
_shadow = true;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue27732 : _IssuesUITest
{
public Issue27732(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Windows] View Position Shifts When Shadows Are Dynamically Removed or Resized";

const string ToggleShadowButton = "ToggleShadowButton";

[Test]
[Category(UITestCategories.Visual)]
public void ViewShouldNotShiftOnShadowChanged()
{
App.WaitForElement(ToggleShadowButton);
for (int i = 0; i < 5; i++)
{
App.Tap(ToggleShadowButton);
}
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/Core/src/Handlers/View/ViewHandlerOfT.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected override void RemoveContainer()
}

#pragma warning disable RS0030 // Do not use banned APIs; Panel.Children is banned for performance reasons. MauiPanel might not be used everywhere though.
var oldParentChildren = PlatformView.Parent is MauiPanel mauiPanel
var oldParentChildren = ContainerView.Parent is MauiPanel mauiPanel
? mauiPanel.CachedChildren
: (PlatformView.Parent as Panel)?.Children;
: (ContainerView.Parent as Panel)?.Children;
#pragma warning restore RS0030 // Do not use banned APIs

var oldIndex = oldParentChildren?.IndexOf(ContainerView);
Expand Down
Loading