Skip to content
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

[Windows] Fix CollectionView broken test #15584

Closed
wants to merge 6 commits into from
Closed

[Windows] Fix CollectionView broken test #15584

wants to merge 6 commits into from

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Jun 12, 2023

Description of Change

Fix CollectionView broken test on Windows.
fix-cv-issue-3

Also added a sample in the Gallery.
fix-cv-issue

Checked the sample from 15492 too.
fix-cv-issue-2

Issues Fixed

Fixes #15529

@Eilon Eilon added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Jun 15, 2023
var h = layout?.ItemSpacing ?? 0;
var v = layout?.ItemSpacing ?? 0;
var margin = WinUIHelpers.CreateThickness(h, v, h, v);
style.Setters.Add(new WSetter(FrameworkElement.MarginProperty, margin));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we only set Margin on Vertical ? what happens if i give ItemsSpacing in a Horizontal layout ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to do more tests to know exactly why, but could have sense to use in both cases. The code comes from XF https://github.com/xamarin/Xamarin.Forms/blob/4f3acdfb0bc98e3ba8e2f3eae86e88602350ee84/Xamarin.Forms.Platform.UAP/CollectionView/StructuredItemsViewRenderer.cs#L241

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the test is broken because in this PR when the methods were moved from the handler to the extension method class, the MinHeight and MinWidth property settings weren't moved along with everything else. The code that was removed just needs to be added back in, the rest of this is unnecessary.

@@ -31,13 +38,18 @@ public static class CollectionViewExtensions
if (layout is null)
return null;

var style = new WStyle(typeof(GridViewItem));

if (layout?.Orientation == ItemsLayoutOrientation.Vertical)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the default value here for MinHeight? why setting it fixes the issue?

@jsuarezruiz jsuarezruiz marked this pull request as draft June 27, 2023 15:06
@samhouts samhouts added this to the .NET 8 GA milestone Jul 26, 2023
@samhouts
Copy link
Member

Please also verify against #15241

@samhouts samhouts added backport/suggested The PR author or issue review has suggested that the change should be backported. and removed t/housekeeping ♻︎ labels Aug 15, 2023
var h = layout?.ItemSpacing ?? 0;
var v = layout?.ItemSpacing ?? 0;
var margin = WinUIHelpers.CreateThickness(h, v, h, v);
style.Setters.Add(new WSetter(FrameworkElement.MarginProperty, margin));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the test is broken because in this PR when the methods were moved from the handler to the extension method class, the MinHeight and MinWidth property settings weren't moved along with everything else. The code that was removed just needs to be added back in, the rest of this is unnecessary.

@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Sep 11, 2023
@samhouts
Copy link
Member

Superceded by #17261

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView backport/suggested The PR author or issue review has suggested that the change should be backported. platform/windows 🪟 stale Indicates a stale issue/pr and will be closed soon t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[regression/8.0.0] [Windows] Fix CollectionView tests that have regressed
5 participants