unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.74k stars 706 forks source link

[WASM] TextBox Vertical Content Alignment/Padding not behaving as expected #16568

Closed iurycarlos closed 3 weeks ago

iurycarlos commented 3 months ago

Current behavior

The Fluent Textbox "vertical alignment" for its text differs between platforms:

WASM: image

DESKTOP: image

We can observe that as long as we change the FontSize or the Height attributes, the result will be different. Probably it is the alignment in skia that is broken, since WASM version seems correct.

Expected behavior

The alignment should be the same in all platforms

How to reproduce it (as minimally and precisely as possible)

Using: Uno.Templates::5.2.31

Run: dotnet new unoapp -o TextBoxAlignment -preset "recommended" -platforms "android" -platforms "maccatalyst" -platforms "wasm" -platforms "windows" -platforms "desktop" -platforms "ios" -theme-service False -vscode False -pwa False -theme "fluent" -presentation "mvux" -config False -di False -log "none" -nav "blank" -http False -loc False -tests "none" -toolkit False -dsp False -id "com.companyname.TextBoxAlignment" -pub "O=TextBoxAlignment"

Add this code to MainPage.xaml:

<TextBox VerticalContentAlignment="Center" Text="Testing Vertical Text Alignment" />

<TextBox
    VerticalContentAlignment="Center"
    FontSize="11"
    Text="Testing FontSize 11" />

<TextBox
    Height="50"
    VerticalContentAlignment="Center"
    Text="Testing height 50" />

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

kazo0 commented 3 months ago

Same strange behavior applies when trying to set a Padding on the TextBox:

<TextBox Padding="20,0,0,0" Text="Testing Padding at 20,0,0,0" />
image

TextBoxAlignment.zip

Youssef1313 commented 3 months ago

image

This is the behavior on WinUI, which appears to match Skia? Am I missing something?

To me, it's actually a Wasm bug, or if https://github.com/microsoft/microsoft-ui-xaml/issues/6324 will be fixed then we can match Skia, but looks like Microsoft views that issue as "By Design" and it's a behavior that's unlikely to change on their side.

So I think, for now, we should make Wasm match WinUI and Skia.

agneszitte commented 1 month ago

@jeromelaban, @Youssef1313, @ramezgerges what is the status of this issue now that https://github.com/unoplatform/uno/pull/15958 is merged?

Youssef1313 commented 1 month ago

15958 is unrelated. The behavior on Skia is matching WinUI. The bad behavior is Wasm

agneszitte commented 1 month ago

15958 is unrelated. The behavior on Skia is matching WinUI. The bad behavior is Wasm

Yes, you are right @Youssef1313, I gave a little try on all platforms with the latest versions and only WASM has the bad behavior here. I adjusted the title of the issue.