-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
area-controls-buttonButton, ImageButtonButton, ImageButtonarea-layoutStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterp/1Work that is important, and has been scheduled for release in this or an upcoming sprintWork that is important, and has been scheduled for release in this or an upcoming sprintplatform/iost/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
There appears to be different behavior for Button.LineBreakMode
on iOS
and Android
in the scenario included in the Steps to Reproduce section.
On iOS
, one can see the Button.Text
does not appear to truncate (Figure 1.1).
On Android
, one can see the Button.Text
does appear to truncate (Figure 1.2).
Is this behavior by design or a bug?
Steps to Reproduce
- Create a new .NET MAUI app
- Replace the
XAML
inMainPage.xaml
with this:
<?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">
<VerticalStackLayout>
<Border Margin="8"
Padding="8"
Background="White"
StrokeShape="{RoundRectangle CornerRadius=4}"
Shadow="{Shadow Radius=4, Opacity=.4}">
<Grid Padding="8"
ColumnDefinitions="*"
RowSpacing="4"
RowDefinitions="*,*,*">
<Label Grid.Row="0"
Grid.Column="0"
Text="Row 0: Hello, World!"
SemanticProperties.HeadingLevel="Level1" />
<Label Grid.Row="1"
Grid.Column="0"
Text="Row 1: Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
<Button Grid.Row="2"
Grid.Column="0"
x:Name="CounterBtn"
Text="Row 2: Why is this happening to this button in this context on this iOS simulator?"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Start"
BorderWidth="1"
BackgroundColor="White"
TextColor="Purple"
BorderColor="Purple"
Padding="0"
LineBreakMode="TailTruncation"/>
</Grid>
</Border>
</VerticalStackLayout>
</ContentPage>
- Replace the
C#
code inMainPage.xaml.cs
with this:
namespace GridButtonLineBreak;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
var textColor = CounterBtn.TextColor;
var backgroundColor = CounterBtn.BackgroundColor;
CounterBtn.BackgroundColor = textColor;
CounterBtn.TextColor = backgroundColor;
}
}
- Run the app on an
iOS
simulator.
Observed: The Button.Text
does not truncate.
Expected: The Button.Text
to truncate.
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
Affected platform versions
iOS 15.5
Did you find any workaround?
In this scenario, instead of using a Button
, try using a Label
w/ TapGestureRecognizer
.
Relevant log output
No response
Metadata
Metadata
Assignees
Labels
area-controls-buttonButton, ImageButtonButton, ImageButtonarea-layoutStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterp/1Work that is important, and has been scheduled for release in this or an upcoming sprintWork that is important, and has been scheduled for release in this or an upcoming sprintplatform/iost/bugSomething isn't workingSomething isn't working