maui
maui copied to clipboard
[regression/8.0.3] Migration breaks the Editor control in multiple ways
Description
The editor stops working properly after upgrading to .NET 8, and the following properties break when you do especially on iOS, I am not sure if this breaks to the same level on iOS.
The following properties break:
- Placeholder - The position of
Placeholderis in the middle for some reason. - VerticleTextAlignment- Setting this to start won't change the placeholder property does not change anymore
- VerticleOptions- Setting this to start won't change the position of place either.
Just to be clear this worked fine with .NET 7.
https://github.com/dotnet/maui/assets/31090457/48db6465-ce7c-4556-b0b9-4aabb69d3844
Steps to Reproduce
-
Create a new Maui app
-
Add an Editor to your page
-
it starts misbehaving like in the video
<Editor FontSize="Large" HeightRequest="200" VerticalTextAlignment="Start" Keyboard="Chat" Placeholder="This is an editor" TextColor="Purple" />
Link to public reproduction project repository
https://github.com/FreakyAli/Maui.FreakyControls/tree/entry_issue
Version with bug
8.0.3
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
Affected platform versions
iOS 17.0, Did not test on lower versions yet
Did you find any workaround?
NOOO
Relevant log output
NA
Verified this on Visual Studio Enterprise 17.9.0 Preview 2(8.0.3). Repro on iOS 17.0, not repro on Android 14.0-API34 with below Project: MAUI.FreakyControls.zip
The issue is that the Placeholder label defaults to vertical Center alignment and there's no way to change it, and it doesn't respond to any other settings. As a quick and dirty hack workaround you can use reflection to set it. I added this code to MauiProgram.cs
#if IOS
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("MyCustomEditorHandler", (handler, view) =>
{
var tv = handler.PlatformView as MauiTextView;
var field = typeof(MauiTextView).GetField("_placeholderLabel", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
var label = field.GetValue(tv) as MauiLabel;
var prop = typeof(MauiLabel).GetProperty("VerticalAlignment", BindingFlags.NonPublic | BindingFlags.Instance);
prop.SetValue(label, UIKit.UIControlContentVerticalAlignment.Top, null);
});
#endif
This issue is not replicable on the latest main branch.
Closing this as it's working now! Thanks