Skip to content

Regression: ability to call nextFocus() on a node to focus its descendant #134854

Closed
@tvolkert

Description

@tvolkert

The following test case was broken by #130812

testWidgets("Requesting nextFocus on node focuses its descendant", (WidgetTester tester) async {
  for (bool canRequestFocus in <bool>{true, false}) {
    final FocusNode node1 = FocusNode();
    final FocusNode node2 = FocusNode();
    await tester.pumpWidget(
      Directionality(
        textDirection: TextDirection.ltr,
        child: FocusTraversalGroup(
          policy: ReadingOrderTraversalPolicy(),
          child: FocusScope(
            child: Focus(
              focusNode: node1,
              canRequestFocus: canRequestFocus,
              child: Focus(
                focusNode: node2,
                child: Container(),
              ),
            ),
          ),
        ),
      ),
    );

    final bool didFindNode = node1.nextFocus();
    await tester.pump();
    expect(didFindNode, isTrue);
    expect(node1.hasPrimaryFocus, isFalse);
    expect(node2.hasPrimaryFocus, isTrue);
  }
});

Before this change, callers could call FocusNode.nextFocus() to focus a descendant node. #130812 caused a regression whereby this no longer works.

We should check in this test and get it passing again :-)

Marking as P1 because it's a regression, but feel free to drop down to P2 if I'm misreading this.

@chunhtai

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: regressionIt was better in the past than it is nowf: focusFocus traversal, gaining or losing focusfound in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions