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

[regression/8.0.0-preview.7.8842] Labels with max lines and linebreakmode not working even with adding handler workaround #18059

Closed
Zack-G-I-T opened this issue Oct 16, 2023 · 1 comment · Fixed by #18087
Assignees
Labels
area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor control-label Label, Span fixed-in-8.0.0-rc.2.9511 Look for this fix in 8.0.0-rc.2.9511 fixed-in-8.0.10 fixed-in-8.0.100-rc.2.9530 Look for this fix in 8.0.100-rc.2.9530 i/regression This issue described a confirmed regression on a currently supported version platform/android 🤖 t/bug Something isn't working
Milestone

Comments

@Zack-G-I-T
Copy link

Zack-G-I-T commented Oct 16, 2023

Description

Adding a label with LineBreakMode="TailTruncation" and MaxLines="2" makes the label only show on one line. Even adding the workaround handler (which fixed this issue in Net7) does not help anymore. I have attached a sample repo showing this - the last label should show on two lines.

Steps to Reproduce

  1. Get repo and see bottom label - it should be on two lines.

Link to public reproduction project repository

https://github.com/Zack-G-I-T/LabelBugNet8

Version with bug

8.0.0-preview.7.8842

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.0-preview.6.8686

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Update code to use the new mapper:

 public static void AllowMultiLineTruncation()
 {
     static void UpdateMaxLines(Microsoft.Maui.Handlers.LabelHandler handler, ILabel label)
     {
         var textView = handler.PlatformView;
         if (label is Label controlsLabel
             && textView.Ellipsize == TextUtils.TruncateAt.End && controlsLabel.MaxLines != -1)
         {
             textView.SetMaxLines(controlsLabel.MaxLines);
         }
     };

     LabelHandler.Mapper.AppendToMapping(
        nameof(Label.LineBreakMode), (h, v) => UpdateMaxLines((LabelHandler)h, v));

     LabelHandler.Mapper.AppendToMapping(
       nameof(Label.MaxLines), (h, v) => UpdateMaxLines((LabelHandler)h, v));
 }

Relevant log output

No response

@Zack-G-I-T Zack-G-I-T added the t/bug Something isn't working label Oct 16, 2023
@samhouts samhouts added platform/android 🤖 control-label Label, Span potential-regression This issue described a possible regression on a currently supported version., verification pending labels Oct 16, 2023
@samhouts samhouts added this to the .NET 8 GA milestone Oct 16, 2023
@ghost ghost added the area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Oct 16, 2023
@samhouts
Copy link
Member

Confirmed that this regressed between 8.0.0-preview.6.8686 and 8.0.0-preview.7.8842. #13836 is the culprit. The obsolete mappers don't seem to be properly forwarding to the new mappers. The workaround is to update to use the new mappers:

 public static void AllowMultiLineTruncation()
 {
     static void UpdateMaxLines(Microsoft.Maui.Handlers.LabelHandler handler, ILabel label)
     {
         var textView = handler.PlatformView;
         if (label is Label controlsLabel
             && textView.Ellipsize == TextUtils.TruncateAt.End && controlsLabel.MaxLines != -1)
         {
             textView.SetMaxLines(controlsLabel.MaxLines);
         }
     };

     LabelHandler.Mapper.AppendToMapping(
        nameof(Label.LineBreakMode), (h, v) => UpdateMaxLines((LabelHandler)h, v));

     LabelHandler.Mapper.AppendToMapping(
       nameof(Label.MaxLines), (h, v) => UpdateMaxLines((LabelHandler)h, v));
 }

@samhouts samhouts added i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Oct 16, 2023
@samhouts samhouts changed the title Maui Net8 - labels with max lines and linebreakmode not working even with adding handler workaround [regression/8.0.0-preview.7.8842] Labels with max lines and linebreakmode not working even with adding handler workaround Oct 16, 2023
@PureWeen PureWeen assigned PureWeen and unassigned mattleibow Oct 17, 2023
@dotnet dotnet locked as resolved and limited conversation to collaborators Nov 24, 2023
@samhouts samhouts added fixed-in-8.0.100-rc.2.9530 Look for this fix in 8.0.100-rc.2.9530 fixed-in-8.0.0-rc.2.9511 Look for this fix in 8.0.0-rc.2.9511 labels Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor control-label Label, Span fixed-in-8.0.0-rc.2.9511 Look for this fix in 8.0.0-rc.2.9511 fixed-in-8.0.10 fixed-in-8.0.100-rc.2.9530 Look for this fix in 8.0.100-rc.2.9530 i/regression This issue described a confirmed regression on a currently supported version platform/android 🤖 t/bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants