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
[Core] Stylesheets on page level now always override parent stylesheets #6772
Conversation
…esheet to child elements to the Element class. It would be weird for a stylesheet to get all parent stylesheets of an element and call Apply on them too. I think it's a good thing that StyleSheet.Apply(Element) really only applies it on the given Element? The main issue was that when the ApplyParentStyleSheets was called, the stylesheet of the element itself wasn't applied, so you could never override parent style elements
Hmm, rebase to 4.1 tag seems to include some extra commits .. is that correct or do I need to change something? |
@csteeg Try rebasing again, this time on master. Thanks! |
/azp run |
No pipelines are associated with this pull request. |
Assert.That((page.Content as Label).BackgroundColor, Is.EqualTo(Color.Blue)); | ||
} | ||
|
||
[Test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the original issue I see two cases defined:
- Styles in the page resources should precede the style in the app
- Styles in a subview should precede the style in the superview
I see cases for the page resource and app scenarios, but not the other one. Would it be useful to add those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an extra test
@@ -1,5 +1,6 @@ | |||
using System.Collections.Generic; | |||
using System.IO; | |||
using System.Linq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a couple of LINQ queries happening here. Can we do without? It might have impact on the performance here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the .concat, but left the .Any(), hope that's ok
Build failure is an unrelated (unit) test |
@csteeg Can you review the conflict?. Thanks! |
# Conflicts: # Xamarin.Forms.Core/StyleSheets/StyleSheet.cs
Fixed |
Are there actions left that I need to take care off @samhouts and @StephaneDelcroix ? |
@csteeg No, nothing needed from you just yet! Thanks!! |
Build is failing:
|
Description of Change
To fix issue #5812 I moved the responsibility for appyling a stylesheet to child elements to the Element class.
It would be weird for a stylesheet to get all parent stylesheets of an element and call Apply on them too. I think it's a good thing that StyleSheet.Apply(Element) really only applies it on the given Element? The main issue was that when the ApplyParentStyleSheets was called, the stylesheet of the element itself wasn't applied, so you could never override parent style elements unless you set the stylesheet after the parent was set.
Issues Resolved
API Changes
None
Platforms Affected
Behavioral/Visual Changes
Stylesheets on page level now always override parent stylesheets if they set the same properties. Before this fix this was only happening when the stylesheet was added to the page after the parent was set
Before/After Screenshots
Not applicable
Testing Procedure
Included two new unit test scenario's
PR Checklist