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
22.21k stars 1.75k forks source link

Editor Scaling creating new lines on older iOS versions #25581

Open tj-devel709 opened 1 week ago

tj-devel709 commented 1 week ago

Description

The issue is when an editor is scaled down on older iOS versions, the text splits in the middle and moves on to the next line causing text to seem to disappear.

This issue was believed to be fixed with: https://github.com/dotnet/maui/pull/24859. Removing the call to SizeThatFits seemed to not cause this scaling issue but it turns out this is only on iOS 17 and up.

On iOS 15.5, the bad editor scaling behavior is still present and on iOS 16.4, it seems that there is still slightly different, but wrong behavior.

Some things I've tried

Inside the MauiTextView.LayoutSubviews method, I am setting a breakpoint and scaling down the editor by 0.5 and then scaling it back up to 1.0. It appears that there are two passes in the LayoutSubviews call and I capture the Bounds and ContentSize. The first image below shows iOS 17.0 and the second shows iOS 15.5. You'll even see when the editor on iOS 15.5 is at the full scale and appears on one line, it still has a much larger ContentSize.Height than the iOS 17.0 equivalent.

Steps to Reproduce

By adding the following code and then sliding the slider value, you'll see the editor will split the text into two lines on iOS 15.5 but not iOS 17+

    <ScrollView>
        <VerticalStackLayout>
            <Slider
                x:Name="mySlider"
                Minimum="0.5"
                Maximum="1"
                Value="1"/>

            <Editor
                x:Name="myEditor"
                Text="1234567890"
                Scale="{Binding Value, Source={x:Reference mySlider}}"
                Background="Red"
                FontSize="32"
                HorizontalOptions="Center"
                HorizontalTextAlignment="Center" />

        </VerticalStackLayout>
    </ScrollView>

Link to public reproduction project repository

No response

Version with bug

8.0.92 SR9.2

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15.5 - iOS 16.4

Did you find any workaround?

No response

Relevant log output

No response

similar-issues-ai[bot] commented 1 week ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

tj-devel709 commented 1 week ago

To note: this happens in net8 and net9!

ninachen03 commented 1 week ago

This issue has been verified using Visual Studio 17.12.0 Preview 5(8.0.82 & 9.0.0-rc.2.24503.2). Can repro this issue at iOS platform on 15.5-17.5. works fine on iOS18 Image