Skip to content

AdvanceFocus does not advance properly through peers and all nested subviews if there are multiple subviews #4146

@tig

Description

@tig

This unit test reproduces the issue. I'm not sure if this was broken before @BDisp did #4085 or not.

  [Fact]
  public void AdvanceFocus_Cycles_Through_Peers_And_All_Nested_SubViews_When_Multiple ()
  {
      var top = new View { Id = "top", CanFocus = true };

      View peer1 = new View
      {
          CanFocus = true,
          Id = "peer1",
      };

      var peer2 = new View
      {
          CanFocus = true,
          Id = "peer2",
     };
      var peer2SubView = new View
      {
          Id = "peer2SubView", CanFocus = true
      };
      var v1 = new View { Id = "v1", CanFocus = true };
      var v2 = new View { Id = "v2", CanFocus = true };
      peer2SubView.Add (v1, v2);

      peer2.Add (peer2SubView);

      top.Add (peer1, peer2);
      top.SetFocus ();

      Assert.Equal (peer1, top.MostFocused);

      top.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
      Assert.Equal (v1, top.MostFocused);

      top.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
      Assert.Equal (v2, top.MostFocused);

      // BUGBUG: This should cycle to peer1 - instead it cycles to v1
      top.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
      Assert.Equal (peer1, top.MostFocused);

      top.Dispose ();
  }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions