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
[Span] Improve formatting inheritance #21191
base: main
Are you sure you want to change the base?
Conversation
Fixes: #21034 Span elements are inconsistently inheriting attributes from their parent Label on Android and iOS. Parent TextDecorations would be inherited on Android if unset, but not on iOS. Additionally, neither platform would inherit FontAttributes if unset. Spans on Android and iOS have been updated to use the parent values for TextDecorations and FontAttributes if these values are not set in the Span itself.
If I recall correctly, if a format property isn't set on the Span, it will use the format property of the label I believe this isn't the right fix for the reported issue |
This does appear to be the case for some formatting properties, but there is inconsistency between platforms. If we compare Android FormattedStringExtensions with iOS FormattedStringExtensions, iOS is missing In my first look at this I was attempting to address issues at the platform level, and can revisit that if that seems like the more appropriate fix? Assigning values when setting up the Spans felt like a more comprehensive and more easily tested fix though (assuming full inheritance when unset is the behavior we want). I may also be missing somewhere else where Span gets formatting information from its associated Label? |
Maybe we could add some explicit interfaces to span itself for ITextElement? And then if "textcolor" isn't set it returns the "textcolor" from the label. We usually use the interfaces to simplify interaction from the platform level and then use the implementation of it to calculate what the platform needs to know. |
Hey just saw this .. seems ifs set a TextColor on my Label, my spans don t respect. |
|
Fixes: #21034
Label has been updated to set corresponding formatting properties on
its Span children if they are set.
One behavior to mention with respect to iOS is that font attributes can
not be forced on font families that do not support them. The .NET 8
templates use
OpenSansRegular
as a font family for Labels by default,and with these changes child spans will now inherit this font family as
well. More context for this behavior is described in issue #1018.
There is some discussion related to Style inheritance in issue #21034,
however this appears to be a more complex issue. Span does not inherit
from Label directly, and as such a style with a target type of Label
can not currently be applied to a Span. This will potentially require
follow up investigation in a separate issue/PR.