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 合并指标
 (30 天内没有已合并 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

贡献者指南