dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.63k stars 1.62k forks source link

8.0.21 update breaks android label wrap feature which causes other controls exceeding layout borders #22083

Closed sencagri closed 3 days ago

sencagri commented 2 weeks ago

Description

After updating to 8.0.21 label word wrap no more working. iOS is working fine.

Before (8.0.14) After (8.0.21)
image image

Code of DataTemplate below. The label control is quoted with double star(for reviewing purposes) in the code.

<DataTemplate x:Key="STOK" x:DataType="ekran:StokListeSatır">
    <c:GridSelected Padding="5,5,5,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            <RowDefinition Height="20" />
            <RowDefinition Height="20" />
            <RowDefinition Height="20" />
            <RowDefinition Height="5" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="{OnIdiom Default={StaticResource darSütunGenişlik}, Tablet={StaticResource darSütunGenişlikTablet}}" />
            <ColumnDefinition Width="{OnIdiom Default={StaticResource darSütunGenişlik}, Tablet={StaticResource darSütunGenişlikTablet}}" />
            <ColumnDefinition Width="{OnIdiom Default={StaticResource sütunGenişlik}, Tablet={StaticResource sütunGenişlikTablet}}" />
        </Grid.ColumnDefinitions>

        <Grid.GestureRecognizers>
            <TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=SeçCommand}" CommandParameter="{Binding K}"></TapGestureRecognizer>
            <SwipeGestureRecognizer Direction="Right" Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=DeğiştirCommand}"></SwipeGestureRecognizer>
            <SwipeGestureRecognizer Direction="Left" Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=MenüCommand}"></SwipeGestureRecognizer>
        </Grid.GestureRecognizers>

        <Border Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" BackgroundColor="Transparent" Padding="3">
            <Border.StrokeShape>
                <RoundRectangle CornerRadius="0,10,0,0" />
            </Border.StrokeShape>
            <Grid RowDefinitions="*,20" BackgroundColor="Transparent">
                **<Label Grid.Row="0" VerticalTextAlignment="Start" BackgroundColor="Transparent" LineBreakMode="WordWrap"
                    Text="{Binding Ad}" FontAttributes="Bold"
                    TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />**
                <Label Grid.Row="1"
                    Text="{Binding Barkod}"
                    FontSize="{StaticResource fontSizeSmall}" MaxLines="1"
                    TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />
            </Grid>
        </Border>

        <Label Grid.Row="0" Grid.Column="1"
            Text="{Binding SatışFiyat, StringFormat='{0:n2}'}"
            FontAttributes="Bold" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" >
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=SatışFiyatDeğiştirCommand}" CommandParameter="{Binding K}"></TapGestureRecognizer>
            </Label.GestureRecognizers>
        </Label>

        <Label Grid.Row="1" Grid.Column="1"
            Text="{Binding SatışFiyatPBKod}" 
            FontSize="{StaticResource fontSizeSmall}" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=SatışFiyatDeğiştirCommand}" CommandParameter="{Binding K}"></TapGestureRecognizer>
            </Label.GestureRecognizers>
        </Label>

        <Label Grid.Row="2" Grid.Column="1"
            Text="{Binding PKDV, StringFormat='% {0:#,0.##}'}"
            FontSize="{StaticResource fontSizeSmall}" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />

        <Label Grid.Row="3" Grid.Column="1" IsVisible="{Binding EtiketBas}"
            Text="{x:Static prop:Resources.Etiket_Bas}" HorizontalTextAlignment="End"
            FontSize="{StaticResource fontSizeSmall}"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />

        <Label Grid.Row="0" Grid.Column="2"
            Text="{Binding AlışFiyat, StringFormat='{0:n2}'}" 
            FontAttributes="Bold" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=AlışFiyatDeğiştirCommand}" CommandParameter="{Binding K}"></TapGestureRecognizer>
            </Label.GestureRecognizers>
        </Label>

        <Label Grid.Row="1" Grid.Column="2"
            Text="{Binding AlışFiyatPBKod}"
            FontSize="{StaticResource fontSizeSmall}" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=AlışFiyatDeğiştirCommand}" CommandParameter="{Binding K}"></TapGestureRecognizer>
            </Label.GestureRecognizers>
        </Label>

        <Label Grid.Row="2" Grid.Column="2"
            Text="{Binding TKDV, StringFormat='% {0:#,0.##}'}"
            FontSize="{StaticResource fontSizeSmall}" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />

        <Label Grid.Row="3" Grid.Column="2"
            Text="{Binding HKar, StringFormat='% {0:#,0.##}'}"
            FontSize="{StaticResource fontSizeSmall}" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />

        <Label Grid.Row="0" Grid.Column="3"
            Text="{Binding İMiktar, StringFormat='{0:#,0.###}'}"
            FontAttributes="Bold" FontSize="{StaticResource fontSizeSmall}" HorizontalTextAlignment="End"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />

        <Label Grid.Row="1" Grid.Column="3"
            Text="{Binding Birim}"
            FontSize="{StaticResource fontSizeSmall}" HorizontalTextAlignment="End" MaxLines="1"
            TextDecorations="{Binding Aktif, Converter={StaticResource aktifToTextDecorationConverter}}" />

        <Border Grid.Row="2" Grid.Column="3" Grid.RowSpan="2" BackgroundColor="{AppThemeBinding Light={StaticResource ButtonBackgroundLight}, Dark={StaticResource ButtonBackgroundDark}}" Padding="3" Margin="2">
            <Border.StrokeShape>
                <RoundRectangle CornerRadius="10,0,0,0" />
            </Border.StrokeShape>
            <Grid RowDefinitions="*" ColumnDefinitions="*,*,*">
                <ImageButton Grid.Column="0"
                    Source="{AppThemeBinding Light=b_edit, Dark=w_edit}" 
                    Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=DeğiştirCommand}" CommandParameter="{Binding K}"  
                    HorizontalOptions="Center" VerticalOptions="Center" />
                <ImageButton Grid.Column="1"
                    Source="{AppThemeBinding Light=b_info, Dark=w_info}" 
                    Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=TümSütunlarCommand}" CommandParameter="{Binding K}"  
                    HorizontalOptions="Center" VerticalOptions="Center" />
                <ImageButton Grid.Column="2"
                    Source="{AppThemeBinding Light=b_menu, Dark=w_menu}" 
                    Command="{Binding Source={RelativeSource AncestorType={x:Type liste:ListeController}}, Path=MenüCommand}" CommandParameter="{Binding K}"  
                    HorizontalOptions="Center" VerticalOptions="Center" />
            </Grid>
        </Border>
        <BoxView Grid.Row="4" Grid.ColumnSpan="4" HeightRequest="1" Color="{AppThemeBinding Light={StaticResource SeperatorLight}, Dark={StaticResource SeperatorDark}}" VerticalOptions="End"></BoxView>
    </c:GridSelected>
</DataTemplate>

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.14 SR3.1

Affected platforms

Android

Affected platform versions

All android versions

Did you find any workaround?

Nope

Relevant log output

No response

jkommeren commented 1 week ago

Does it still need a repro? There is code supplied right?

Im having the same issue. Its not very complex to reproduce. I could host the code on GitHub if desired

PureWeen commented 6 days ago

@jkommeren If you could that'd be very helpful!

sencagri commented 6 days ago

I will create a repo for it.

jkommeren commented 4 days ago

Does it still need a repro? There is code supplied right?

Im having the same issue. Its not very complex to reproduce. I could host the code on GitHub if desired

Well I spoke to soon. Not so sure the underlying cause is the same in my own case. I'll create a separate ticket for it once I've narrowed it down.

(This bug might still be valid though)

@sencagri good luck!

sencagri commented 4 days ago

Hello again,

I have identified the bug and its cause. The issue in Android systems is caused by the ItemSizingStrategy property when it is set to "MeasureFirstItem."

Below is the repro link: https://github.com/sencagri/layout_exceed_bug/

Thank you.

PureWeen commented 3 days ago

Duplicate of #21967