Skip to content

Button text does not update when CharacterSpacing is applied #21488

@tdeborde2

Description

@tdeborde2

Description

Button text is not updated by either setting the Button.Text property or updating binding property when CharacterSpacing is applied.

Steps to Reproduce

  1. Create new .NET MAUI App
  2. In the template projects MainPage.xaml modify the button tag to include the CharacterSpacing attribute and set the value to greater than 0.
  3. Run the application and click the button.
  4. Observe the button text does not update.

Link to public reproduction project repository

https://github.com/tdeborde2/ButtonCharSpacingIssue

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.101

Affected platforms

iOS, macOS

Affected platform versions

No response

Did you find any workaround?

Calling SetAttributedTitle method resolves the issue.

        var platformButton = button.Handler?.PlatformView as UIKit.UIButton;
        if (platformButton != null)
        {
            var titleLabel = platformButton.TitleLabel;
            titleLabel.Text = button.Text;

            var attributedText = titleLabel.AttributedText?.WithCharacterSpacing(button.CharacterSpacing);
            platformButton.SetAttributedTitle(attributedText, UIKit.UIControlState.Normal);
        }

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-buttonButton, ImageButtonplatform/iospotential-regressionThis issue described a possible regression on a currently supported version., verification pendings/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions