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

[MAUI 8] Label measurement is wrong, TailTruncation not working #19218

Closed
omghb opened this issue Dec 5, 2023 · 7 comments
Closed

[MAUI 8] Label measurement is wrong, TailTruncation not working #19218

omghb opened this issue Dec 5, 2023 · 7 comments
Labels

Comments

@omghb
Copy link

omghb commented Dec 5, 2023

Description

image

  • On iOS and Android the Label does not respect the Width of the container
  • On Windows the Label text is clipped but the TailTruncation is not applied

Steps to Reproduce

  1. Create new MAUI 8 App
  2. Replace MainPage.xaml with the following content:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.MainPage">

    <ScrollView>
        <VerticalStackLayout Padding="30" Spacing="25">
            <Grid BackgroundColor="LightBlue">
                <HorizontalStackLayout>
                    <Label Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non tincidunt ligula, sit amet blandit arcu." 
                           LineBreakMode="TailTruncation"/>
                </HorizontalStackLayout>
            </Grid>
            <Button x:Name="CounterBtn" Text="Click me"/>
        </VerticalStackLayout>
    </ScrollView>

</ContentPage>
  1. run the app

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows

Affected platform versions

iOS 17, Android 13, Windows 10

Did you find any workaround?

No response

Relevant log output

No response

@omghb omghb added the t/bug Something isn't working label Dec 5, 2023
@PureWeen
Copy link
Member

PureWeen commented Dec 5, 2023

@omghb by default the HorizontalStackLayout uses infinite horizontal space to layout its content, so the content inside the HSL is going to extend beyond the Grid container. The reason you're seeing a difference here is related to a difference in the platforms on what platforms will clip the children.

This talks about the differences here https://learn.microsoft.com/dotnet/maui/migration/layouts

A StackLayout continues in its stacking direction until it runs out of content. It does not subdivide its container along that axis. If you want to limit your content to a constrained space in a direction, you should use another layout such as a Grid.

@PureWeen PureWeen added the s/needs-info Issue needs more info from the author label Dec 5, 2023
@ghost
Copy link

ghost commented Dec 5, 2023

Hi @omghb. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@PureWeen PureWeen added layout-stack legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels Dec 5, 2023
@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Dec 11, 2023
@ghost
Copy link

ghost commented Dec 11, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@omghb
Copy link
Author

omghb commented Dec 11, 2023

@PureWeen Thanks for the information.

For me this behavior is a bit strange:

so the content inside the HSL is going to extend beyond the Grid container.

I would have expected that the parent Grid would "clip" all its children.

However, by using Grids we should be able to solve our issues.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author s/no-recent-activity Issue has had no recent activity labels Dec 11, 2023
@mattleibow
Copy link
Member

Layout can clip, but it appears since Forms days we never had the default to clip. Setting IsClippedToBounds = true will make it work as you expect:

https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.layout.isclippedtobounds?view=net-maui-8.0

@mattleibow mattleibow added s/needs-info Issue needs more info from the author and removed s/needs-attention Issue has more information and needs another look labels Dec 11, 2023
@ghost
Copy link

ghost commented Dec 11, 2023

Hi @omghb. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@omghb
Copy link
Author

omghb commented Dec 12, 2023

@mattleibow Thanks for the explanation.

✔ The setting IsClippedToBounds="True" results in the behavior that I have expected.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Dec 12, 2023
@PureWeen PureWeen closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2024
@Eilon Eilon added area-controls-label Label, Span and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants