-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] - Fix Grid layout not updating when Row/Column changed dynamically #30206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
prakashKannanSf3972
wants to merge
7
commits into
dotnet:main
Choose a base branch
from
prakashKannanSf3972:fix-20404
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
64ccee3
Fixed-Grid-Row-Column-Switches
prakashKannanSf3972 c86b8ab
Added-SnapShots
prakashKannanSf3972 3a777e0
Updated-Fix
prakashKannanSf3972 6740d77
Removed-Unwanted-In-Test
prakashKannanSf3972 7870ac9
Updated-Compilation-Symbol
prakashKannanSf3972 dc74de7
.
prakashKannanSf3972 5e4a947
Addressed AI summary
Dhivya-SF4094 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+39.2 KB
...rols/tests/TestCases.Android.Tests/snapshots/android/AfterGridColumnToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.4 KB
...ontrols/tests/TestCases.Android.Tests/snapshots/android/AfterGridRowToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 138 additions & 0 deletions
138
src/Controls/tests/TestCases.HostApp/Issues/Issue20404.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 20404, "Dynamic Grid Row/Column changes don't trigger layout update on Windows until window resize", PlatformAffected.UWP)] | ||
| public class Issue20404 : TestContentPage | ||
| { | ||
| Grid dynamicGrid; | ||
| Button toggleRowButton; | ||
| Button toggleColumnButton; | ||
|
|
||
| protected override void Init() | ||
| { | ||
| Content = CreateMainGrid(); | ||
| } | ||
|
|
||
| Grid CreateMainGrid() | ||
| { | ||
| Grid mainGrid = new Grid | ||
| { | ||
| RowSpacing = 8, | ||
| ColumnSpacing = 8, | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = GridLength.Star }, | ||
| new RowDefinition { Height = GridLength.Star }, | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Auto } | ||
| }, | ||
| ColumnDefinitions = | ||
| { | ||
| new ColumnDefinition { Width = GridLength.Star }, | ||
| new ColumnDefinition { Width = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| AddStaticGrids(mainGrid); | ||
| AddDynamicGrid(mainGrid); | ||
| AddControlButtons(mainGrid); | ||
| return mainGrid; | ||
| } | ||
|
|
||
| void AddStaticGrids(Grid parent) | ||
| { | ||
| Grid topLeft = CreateStaticGrid("Static\n(0,0)", Colors.LightBlue); | ||
| Grid.SetRow(topLeft, 0); | ||
| Grid.SetColumn(topLeft, 0); | ||
| parent.Children.Add(topLeft); | ||
|
|
||
| Grid topRight = CreateStaticGrid("Static\n(0,1)", Colors.LightCoral); | ||
| Grid.SetRow(topRight, 0); | ||
| Grid.SetColumn(topRight, 1); | ||
| parent.Children.Add(topRight); | ||
|
|
||
| Grid bottomLeft = CreateStaticGrid("Static\n(1,0)", Colors.LightGreen); | ||
| Grid.SetRow(bottomLeft, 1); | ||
| Grid.SetColumn(bottomLeft, 0); | ||
| parent.Children.Add(bottomLeft); | ||
| } | ||
|
|
||
| Grid CreateStaticGrid(string labelText, Color backgroundColor) | ||
| { | ||
| Grid grid = new Grid { BackgroundColor = backgroundColor }; | ||
| Label label = new Label | ||
| { | ||
| Text = labelText, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| TextColor = Colors.Black | ||
| }; | ||
|
|
||
| grid.Children.Add(label); | ||
| return grid; | ||
| } | ||
|
|
||
| void AddDynamicGrid(Grid parent) | ||
| { | ||
| dynamicGrid = new Grid | ||
| { | ||
| BackgroundColor = Colors.DarkBlue, | ||
| AutomationId = "DynamicGrid" | ||
| }; | ||
|
|
||
| Label label = new Label | ||
| { | ||
| Text = "DYNAMIC\nGRID", | ||
| TextColor = Colors.White, | ||
| FontAttributes = FontAttributes.Bold, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| AutomationId = "DynamicLabel" | ||
| }; | ||
|
|
||
| dynamicGrid.Children.Add(label); | ||
| Grid.SetRow(dynamicGrid, 1); | ||
| Grid.SetColumn(dynamicGrid, 1); | ||
|
|
||
| parent.Children.Add(dynamicGrid); | ||
| } | ||
|
|
||
| void AddControlButtons(Grid parent) | ||
| { | ||
| toggleRowButton = new Button | ||
| { | ||
| Text = "Toggle Row (Current: 1)", | ||
| AutomationId = "ToggleRowButton" | ||
| }; | ||
| toggleRowButton.Clicked += OnToggleRowClicked; | ||
|
|
||
| toggleColumnButton = new Button | ||
| { | ||
| Text = "Toggle Column (Current: 1)", | ||
| AutomationId = "ToggleColumnButton" | ||
| }; | ||
| toggleColumnButton.Clicked += OnToggleColumnClicked; | ||
|
|
||
| StackLayout buttonStack = new StackLayout | ||
| { | ||
| Orientation = StackOrientation.Horizontal, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| Children = { toggleRowButton, toggleColumnButton } | ||
| }; | ||
|
|
||
| Grid.SetRow(buttonStack, 3); | ||
| Grid.SetColumnSpan(buttonStack, 2); | ||
| parent.Children.Add(buttonStack); | ||
| } | ||
|
|
||
| void OnToggleRowClicked(object sender, EventArgs e) | ||
| { | ||
| Grid.SetRow(dynamicGrid, 0); | ||
| toggleRowButton.Text = $"Toggle Row (Current: 0)"; | ||
| } | ||
|
|
||
| void OnToggleColumnClicked(object sender, EventArgs e) | ||
| { | ||
| Grid.SetColumn(dynamicGrid, 0); | ||
| toggleColumnButton.Text = $"Toggle Column (Current: 0)"; | ||
| } | ||
| } |
Binary file added
BIN
+18.3 KB
src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/AfterGridColumnToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.7 KB
src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/AfterGridRowToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20404.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue20404 : _IssuesUITest | ||
| { | ||
| public Issue20404(TestDevice testDevice) : base(testDevice) { } | ||
|
|
||
| public override string Issue => "Dynamic Grid Row/Column changes don't trigger layout update on Windows until window resize"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Layout)] | ||
| public void DynamicGridRowColumnChangeShouldInvalidate() | ||
| { | ||
| App.WaitForElement("ToggleRowButton"); | ||
| App.Tap("ToggleRowButton"); | ||
| VerifyScreenshot("AfterGridRowToggled"); | ||
| App.WaitForElement("ToggleColumnButton"); | ||
| App.Tap("ToggleColumnButton"); | ||
| VerifyScreenshot("AfterGridColumnToggled"); | ||
| } | ||
| } |
Binary file added
BIN
+49 KB
...ntrols/tests/TestCases.WinUI.Tests/snapshots/windows/AfterGridColumnToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.8 KB
src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/AfterGridRowToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+47.5 KB
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/AfterGridColumnToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.1 KB
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/AfterGridRowToggled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.