xamarin/Xamarin.Forms

[Shell] Control loses focus after appearing

開放

#4,755 建立於 2018年12月15日

 (1 則留言) (0 個反應) (0 位負責人)C# (1,926 個分叉)batch import
4.0.0a/shell :shell:e/4 :clock4:help wantedinactivet/bug :bug:up-for-grabs

倉庫指標

星標
 (5,644 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Description

I have a page that sets focus to an Entry and then pre-selects text. This works fine in a TabbedPage, but within Shell it's losing focus.

Losing focus: https://www.screencast.com/t/Daq7XY40

protected override void OnAppearing()
        {
            base.OnAppearing();
            MakeSelection();
        }

        private void MakeSelection()
        {
            FirstEntry.Focus();
            FirstEntry.CursorPosition = 4;
            FirstEntry.SelectionLength = 11;
        }

If I set the ShellContent to be ShellSections (bottom tabs) and yet also displayed in the flyout, this is not a problem. It seems navigation from ShellItem to ShellItem introduces an animation that is causing this issue.

Not losing focus: https://www.screencast.com/t/GBJOIi9a

This is fine:

<Shell ...>
<ShellItem FlyoutDisplayOptions="AsMultipleItems" Title="Releases">
        <ShellContent Title="3.1.0" ContentTemplate="{DataTemplate views:ThreeOnePage}" Icon="iconXamagon"/>
        <ShellContent Title="3.2.0" ContentTemplate="{DataTemplate views:ThreeTwoPage}" Icon="iconXamagon"/>
        <ShellContent Title="3.3.0" ContentTemplate="{DataTemplate views:ThreeThreePage}" Icon="iconXamagon"/>
        <ShellContent Title="3.4.0" ContentTemplate="{DataTemplate views:ThreeFourPage}" Icon="iconXamagon"/>
        <ShellContent Title="3.5.0-pre" ContentTemplate="{DataTemplate views:ThreeFivePage}" Icon="iconXamagon"/>
    </ShellItem>
</Shell>

This is not:

<Shell ...>
        <ShellContent Title="3.1.0" ContentTemplate="{DataTemplate views:ThreeOnePage}" Icon="iconXamagon"/>
        <ShellContent Title="3.2.0" ContentTemplate="{DataTemplate views:ThreeTwoPage}" Icon="iconXamagon"/>
        <ShellContent Title="3.3.0" ContentTemplate="{DataTemplate views:ThreeThreePage}" Icon="iconXamagon"/>
        <ShellContent Title="3.4.0" ContentTemplate="{DataTemplate views:ThreeFourPage}" Icon="iconXamagon"/>
        <ShellContent Title="3.5.0-pre" ContentTemplate="{DataTemplate views:ThreeFivePage}" Icon="iconXamagon"/>
</Shell>

Steps to Reproduce

  1. Navigate to the 3.2.0 page from the flyout

Expected Behavior

Focus set in OnAppearing is not lost until the user changes focus..

Actual Behavior

Focus is lost a split second after appearing.

Basic Information

  • Version with issue: 4.0-pre1

Screenshots

https://www.screencast.com/t/Daq7XY40

https://www.screencast.com/t/GBJOIi9a

Reproduction Link

Archive.zip

Parent: #2415

貢獻者指南