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
21.86k stars 1.68k forks source link

[iOS] Automatic scroll to Editor control covers screen from top #23438

Open awattar opened 1 week ago

awattar commented 1 week ago

Description

I'm happy that we finally have scrollable Editors (thanks to https://github.com/dotnet/maui/issues/12485) and automatic scroll on iOS when soft input keyboard would cover a text entry (thanks to behavior change KeyboardAutoManagerScroll https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-8?view=net-maui-8.0#behavior-changes).

BUT it seems that one of these changes (or sth else) have introduced another issue - when entering Editor control that is positioned around the middle of the screen - whole top window area is shifted down and covered by background.

Simulator Screen Recording - iPhone SE (2nd generation) - 2024-07-04 at 17 44 56

Similar to https://github.com/dotnet/maui/issues/22848

Steps to Reproduce

  1. Create empty MAUI project with default values.
  2. Remove Image and add Editor controls on the MainPage.xaml so the Editor will be positioned around the middle of the screen.

    
    <?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"
             x:Class="OOO.MainPage">
    
    <ScrollView>
        <VerticalStackLayout
            Padding="30,0"
            Spacing="25">
    
            <Label
                Text="Hello, World!"
                Style="{StaticResource Headline}"
                SemanticProperties.HeadingLevel="Level1" />
    
            <Label
                Text="Welcome to &#10;.NET Multi-platform App UI"
                Style="{StaticResource SubHeadline}"
                SemanticProperties.HeadingLevel="Level2"
                SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
    
            <Button
                x:Name="CounterBtn"
                Text="Click me" 
                SemanticProperties.Hint="Counts the number of times you click"
                Clicked="OnCounterClicked"
                HorizontalOptions="Fill" />
    
            <Editor
                Keyboard="Plain"
                IsTextPredictionEnabled="False"
                Placeholder="Placeholder"
                FontSize="17"
                HeightRequest="100"/>
    
        </VerticalStackLayout>
    </ScrollView>


3. Run the app on device with smaller screen like iPhone SE (2nd gen) or iPhone 8.
4. Using soft keyboard add some lines until Editor scroll appears.
5. Close soft keyboard (use Done above the keyboard or add `HideSoftInputOnTapped = true;` in code behind to allow closing keyboard when tapping on empty space https://github.com/dotnet/maui/issues/11881#issuecomment-1906896730).
6. Scroll Editor content to end and tap on the last line to show keyboard.
7. Close keyboard.
8. Scroll top and tap on the first line.
9. Issue appears.
10. Close keyboard and tap once gain on the first Editor line - there is no issue - keyboard is properly displayed on bottom without shifting the view.

### Link to public reproduction project repository

_No response_

### Version with bug

8.0.21 SR4.1

### 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 17.5

### Did you find any workaround?

No.

### Relevant log output

_No response_
github-actions[bot] commented 1 week ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

kevinxufei commented 1 week ago

This issue has been verified using Visual Studio 17.11.0 Preview 2.1(8.0.61 & 8.0.40 & 8.0.21 & 8.0.14). Can repro on iOS platform.

PureWeen commented 1 week ago

@tj-devel709 is this a duplicate or does one of your PRs fix this?

tj-devel709 commented 1 week ago

This smells like a slightly new issue.. I'll have to look into this one more!