xamarin/Xamarin.Forms

[Shell] Control loses focus after appearing

Aberta

#4.755 aberto em 15 de dez. de 2018

 (1 comentário) (0 reação) (0 responsável)C# (1.926 forks)batch import
4.0.0a/shell :shell:e/4 :clock4:help wantedinactivet/bug :bug:up-for-grabs

Métricas do repositório

Stars
 (5.644 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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

Guia do colaborador